Railway

Deploy Hugo | Static Site Starter Built by a Dockerfile

Hugo starter for Railway — pinned build, Caddy serving, real 404s.

Deploy Hugo | Static Site Starter Built by a Dockerfile

hugo-railway-starter

ak40u/hugo-railway-starter

Just deployed

Deploy and Host Hugo on Railway

A minimal Hugo site — Markdown in, static HTML out, served by Caddy. The build is described by a Dockerfile, so it does not depend on which builder the platform happens to be using this month.

About Hosting Hugo

A Hugo site has no runtime to speak of: the interesting work all happens at build time, and what gets served afterwards is a directory of files. That makes hosting it simple and makes the build the only thing that can break. It breaks in a specific way — build instructions written for one builder stop being read when the platform switches to another, and the failure looks like the site has no start command rather than like a configuration mismatch.

Common Use Cases

  • A personal site, blog or changelog
  • Documentation that lives next to the code in the same repository
  • A landing page you want to edit as Markdown rather than as templates

Dependencies for Hugo Hosting

  • hugomods/hugo:0.164.0 — the build stage, pinned to an exact Hugo version
  • caddy:2-alpine — the serving stage

Deployment Dependencies

Implementation Details

The existing Hugo template on Railway describes its build in nixpacks.toml. Railway has since moved to a different builder, which does not read that file and then finds nothing to run:

⚠ Script start.sh not found
railpack process exited with an error

Nothing about the site is wrong. The instructions are simply addressed to a builder that is no longer in use — and no amount of editing the content will fix it.

This template ships a Dockerfile instead. A Dockerfile is not a hint that a builder may reinterpret; it is the build itself, and it produces the same image regardless of what the platform does next. Hugo is pinned to an exact version for the same reason.

baseURL is supplied at build time from RAILWAY_PUBLIC_DOMAIN:

ARG RAILWAY_PUBLIC_DOMAIN
RUN if [ -n "$RAILWAY_PUBLIC_DOMAIN" ]; then \
      hugo --minify --baseURL "https://$RAILWAY_PUBLIC_DOMAIN/"; \
    else \
      hugo --minify --baseURL "/"; \
    fi

so canonical URLs, RSS links and sitemaps are correct without editing the config after each deploy, and a local docker build still works without that variable.

Caddy serves the output on $PORT with gzip and zstd compression and a real 404 page rather than a bare status code.

Getting Started

hugo new content posts/my-post.md

Write, remove draft: true, commit, push. Layouts live in layouts/; the shared shell is layouts/_default/baseof.html.

Why Deploy Hugo on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying Hugo on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.


Template Content

hugo-railway-starter

ak40u/hugo-railway-starter

More templates in this category

View Template
Pixelfed
Explore + Share beautiful photos and videos on the Fediverse

Evan Boehs
29
View Template
NodeBB
Node.js based forum software built for the modern web

Six
63
View Template
WordPress + MySQL
Zero Config | One click | WordPress | Docker | MySQL

YAV.AI
1.4K