Hugo + Nginx + Cloudflare: a clean, fast stack
On this page
Static sites are a great fit when you want predictable behaviour and simple operations:
- response codes,
- canonical URLs,
- and you minimise plugin footprint.
Build step
hugo --minify
Hugo docs: https://gohugo.io/documentation/
Nginx: serve static + cache assets
location / {
try_files $uri $uri/ /index.html =404;
}
location ~* \.(css|js|png|jpg|jpeg|gif|svg|webp|woff2)$ {
expires 30d;
add_header Cache-Control "public, max-age=2592000, immutable";
try_files $uri =404;
}
Cloudflare: keep it simple
- proxy enabled
- “Always Use HTTPS”
- HTTP/3 enabled
- optional caching rules for assets
Cloudflare docs: https://developers.cloudflare.com/
Keeping older paths working
If you have older .html paths you still want to serve, Hugo aliases are a tidy way to map them to the current page.