Hugo on Cloudflare Pages
Cloudflare Pages??
Cloudflare Pages are static site hosts similar to the various Git* static pages such as Gitlab Pages or Github Pages. Previously this site was deployed using the AWS CLI and a classic S3 + Cloudfront build-out. While this was intriguing it was very much overkill for a blog like this and required too much devops toil for my taste.
This post is not an endorsement nor sponsored ad for Cloudflare
Deploying Hugo to Gitlab Pages
The Cloudflare docs on deploying to Hugo are pretty straightforward:
https://developers.cloudflare.com/pages/framework-guides/deploy-a-hugo-site
the one thing i’ll call out is that while the build log within Cloudflare PAges says the site built - if you’re presented with a blank page check that the HUGO_VERSION
is configured in your CI/CD variables².
You can find that with:
hugo version
hugo v0.83.0-DEV linux/amd64 BuildDate=unknown
such that BOTH Production
and Preview
have:
HUGO_VERSION 0.83.0
Once that’s all setup yu should have all the benefits of Pages:
- Analytics (still running Google Analytics along side for comparison)
- SSL/TLS (let’s encrypt ftw)
- HTTP -> HTTPS promotion
- DNSSEC
- GitOps
- Preview Environments
Could all of these features be done with readily available tools? Sure - HAProxy + Let’s Encrypt solves many of these but its nice for someone else to do it for a change 💅.
Its been quite an enjoyable dev UX and I’ll be using Cloudflare Pages going forward for other projects.