Skip to content


Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Hugo Static Site Running on GCP Free Tier VM

This project is to create a site with Hugo and deploy it to GCP in < 5min.

Accompanying Blog Posts:

  1. The Making of (Hugo, Caddy, + GCP)
  2. CI/CD for (Hugo + Cloud Build)

NOTE: For a static site like this, the built in hugo deploy approach to host directly within a GCP/AWS/Azure bucket might be easier/more scalable, but I wanted to familiarize myself with various server options (first I used nginx, and then switched to caddy b/c of its automatic https config!) and eventually want to do some benchmarking on the f1-micro instance to see what kind of load it can handle.


  • Install hugo (brew install hugo)
  • Install docker (brew cask install docker)
  • Install google cloud sdk (brew cask install google-cloud-sdk && gcloud init)

Site Setup Instructions

Before starting, update the following:

    <SITE_NAME> (within ./Makefile, e.g. my-website)
    <DOMAIN(S)> (within ./Caddyfile, e.g.
    <EMAIL_ADDRESS> (within ./Caddyfile, e.g.

to their appropriate values.

  1. Run $make create-site (uses
    • Creates the hugo site and moves it into this directory
  2. Run $make create-project
    • Creates a new GCP project
  3. enable billing using the project link output by previous command
  4. Run $make vm-setup
    • Enables and
    • Reserves a static IP for the site
    • Adds http and https firewall rules
    • Creates f1-micro vm,
    • Configures your local docker install to use google container registry (gcr)
    • Configures VM docker install to be able to use google container registry
  5. Run $make deploy
    • Builds hugo site
    • Builds caddy based docker container containing site files
    • Tags and pushes to gcr
    • Removes currently running containers on VM
    • Starts container on VM using new container image
  6. Run $make list-vms --> create A record for domain (not automated)
    • Go to your DNS provider and point your domain to the VM static IP
    • It's also useful to add a www CNAME record (to automatiaclly point requests like to
    • You also need to update the Caddyfile to reflect your domain and enable TLS

CI/CD Setup Instructions

Before starting, update the following:

    <SITE_NAME> (within ./Makefile, e.g. my-website)
    <REPO_NAME> (within ./Makefile, e.g. my-cloud-source-repo-mirroring-a-github-repo)
    <USER_NAME> (within ./Makefile, e.g. myusername -- this shoud be the username of the user when you SSH into the VM)

to their appropriate values.

  1. Mirror GitHub repo in Cloud Source ( -- assuming primary site repo is in GitHub
  2. Run `make setup-cloud-build
    • Enables the Cloud Build API
    • Adds the necessary IAM roles to the Cloud Build service account
    • Creates the Cloud build Trigger


  • Tune caddy config
  • Add CDN (eventually)


No description, website, or topics provided.






No releases published


No packages published