Host A Static Website With Firebase Hosting Service

👋 Front-End Developer with a flair for competitive programming & robotics. Expert in 3D CAD design, YouTube educator. Innovating from Oaxaca, México.
Search for a command to run...

👋 Front-End Developer with a flair for competitive programming & robotics. Expert in 3D CAD design, YouTube educator. Innovating from Oaxaca, México.
Great article!!, I think this is the simplest way to host a static website on Firebase, thank you.
Nice Content!! Thanks for sharing!!!
Hello everyone 👋, welcome back to another article, today are going to dive into a very cool graph algorithm called "Tarjan", we are going to see what it is, how it works, what it's used for, and we are going to upsolve two very cool competitive prog...

Introduction Hello everyone! 😄 Welcome back to my blog! Today, we're diving into the fascinating world of greedy algorithms in competitive programming. If you've ever wondered how to spot a problem screaming for a greedy solution or how to tackle th...

Introduction Hey there, fellow coders! Today, we're going to navigate through the exciting world of dynamic programming, tackling a captivating competitive programming problem along the way. We'll be stepping into the shoes of game strategists, playi...

Introduction Hello everyone, in this post we'll be mastering the 2D prefix sum array and 2D segment Tree while we solve a very interesting competitive programming problem to better understand these structures and their capabilities. Forest Queries Pr...

Introduction Hello everyone, in this post we will look in detail at the solution to two similar, very classic DP problems: 'Roads' and 'Organizing Tiles', as well as their implementation in C++, altho the solution can be implemented in the language o...

Hello everyone, in today's post I wanted to show you how to use the google cloud hosting service. using that service, we can host static web pages easily, free, and securely.
Firebase hosting will provide you impressive good speed without the need for separate CDN and it's FREE, easy to use, and provides the SSL certificate so that your website will be hosted securely with HTTPS.
Open Firebase Console ==> Sign in with your Google account ==> Create project ==> Add title ==> Enable Google analyitics for your country.
See the images below for guidance.







Simply execute the following command:
npm install -g firebase-tools
or you can use:
yarn global add firebase-tools
firebase login
This will redirect you to the sign-in page in the browser, where you just need to simply sign in.
After successfully given access, you should get the below message on the browser

On your command prompt, simply execute the following command:
firebase init
After executing this command you should see the following screen:

After pressing enter to the question
are you ready to proceed?
you should select the option:
Hosting: Configure files for Firebase Hosting and (optionally) set up GitHub Action deploys
Use arrows to change selection and select using the spacebar, then press enter.
Once the Hosting option is selected, they'll provide the option to choose an existing project or create a new one. As we have already created a sample static project, you need to just choose the existing option and press enter.
After pressing enter you should see your Firebase project, select it, and press enter.
Then it will ask you for a name for the public directory, you can put the same name as your project, and after pressing enter the following question should appear

If your page is a single page like mine you should answer yes.
After we are done with the configuration we need to run the following command:
firebase serve
If we followed all of the steps correctly, in the folder created at the beginning we will find another folder and inside an index.html file that will be shown on localhost:5000

After watching the screen above without showing problems then we can exit with Ctrl+C
We're almost done!, now it's time to delete the index.html file and replace it with our wanted index.html, index.css, images, and icon files.
Back at the CMD terminal we can repeat step 5 and now we should see our website on localhost:5000, it's likely that we see the old file instead of the new one so to fix that make sure to refresh the browser with Ctrl+Shift+R

After making sure everything works properly on localhost:5000, we can now exit and proceed with the deploy
firebase deploy
As we can see from the image above, after the deploy it's complete, we should get a Hosting URL, if we paste that into our web browser we should see our website.
We are Done!
In the likely case that you don't want your website URL to look like this: https://sample-9f6cf.web.app/ and want to use a custom domain instead, we can do just that from the Project dashboard, just follow the images below.



In my case, I already had a domain from https://domains.google/ and after following the three steps from the image above we should get a register type, host, and value (image below).

Now we need to go to Google Domains ==> Select your domain ==>DNS ==> Manage custom records ==> Create new record and enter the values there ==> Save.
See the images below for guidance.


Now we should wait some time, normally it's a few minutes, and after that, we are done hosting our website with firebase!.
I really hope this post has taught you how to host your website with Firebase and if you have any suggestions or ideas, let me know in the comments below, see you in the next post!.