Hosting a static site for free on Firebase

Static site detail

This site is generated with Hugo, a static site generator written in Golang. An advantage of this is the site is easily hosted.

Originally it lived on Aerobatic.io, since they had a great plugin with Bitbucket to automatically build and deploy on each git push and their free tier supported custom domains with SSL.

However, Aerobatic recently tweaked their plans and require a paid plan for the custom domain, so I switched it to Google’s Firebase.

Firebase’s free tier supports custom domains with SSL and a generous resource allowance. If your site requires more, they have plenty of upgrade options.

Configure Firebase

First you’ll need to create a project in Firebase, which is done through a simple UI in the Firebase console

Install Firebase CLI

The Firebase Command Line Interface (CLI) enables you to deploy your site from your local machine to the hosted platform.

A pre-requesite of installing the CLI is npm, meaning you have to have Node.js installed. Install the CLI using:

npm install -g firebase-tools

Node.js already existed on my Fedora box, but I needed to adjust my npm permissions. Though this is only necessary if you get an error while installing the CLI.

Configure site with Firebase

Firebase configuration is stored in a firebase.json file. I executed the following commands from the root folder of my Hugo site, leaving Firebase’s default ‘public’ folder setting as it’s the same path I use for my generated Hugo output.

firebase login
firebase init

Generate site and deploy

My Hugo build remains the same commands as before:

# Delete previously-generated site for a clean build
rm -rf public
# Generate static site with hugo
hugo

Then simply upload the generated site using the CLI:

firebase deploy

And the deployed content is now available at the URL associated with your project!

Next steps

Check out the Firebase documentation to see all they have available.

I migrated over my subdomain www.M0d3rnC0ad.com using the instructions in their docs.

◀   How to set up free SSL certificates with Let's Encrypt Consuming data via REST service with Golang   ▶

Comments