Unerdwear

Developer tools · lightweight guides · security notes

Hugo + Nginx + Cloudflare: a clean, fast stack

An open padlock sitting on a keyboard
Source: Unsplash.

Static sites are a great fit when you want predictable behaviour and simple operations:

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

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.

Last updated: 2026-01-02