This are all the steps needed to deploy your static Hugo page on Firebase for free (until you exceed the traffic of the free tier a.k.a Spark plan).
Firebase Setup
- Go to https://console.firebase.google.com and create a new project.
- Install
firebase-tools(node.js):npm install -g firebase-tools - Login to firebase:
firebase login(opens a browser for authentication). - In the root of your Hugo site initialize:
firebase init - Choose Hosting in the feature question.
- Choose the project you just set up.
- Accept the default for database rules file.
- Accept the default for the publish directory which is
public. - Choose No in the question if it is a single-page app.
Deploy
Simply execute hugo && firebase deploy and your site will be up in no time.
Alternatively create a deploy.sh file:
#!/bin/sh
rm -rf public
hugo
firebase deploy
CI Setup
- Generate a deploy token using
firebase login:ci - Setup your CI
- Add the token to a private variable like
$FIREBASE_DEPLOY_TOKEN
This is a private secret and it should not appear in a public repository.
- Add a step in your build to do
firebase deploy --token $FIREBASE_DEPLOY_TOKEN
