---
title: "Deploy Hugo | Static Site Starter Built by a Dockerfile"
description: "Hugo starter for Railway — pinned build, Caddy serving, real 404s."
category: "Blogs"
url: https://railway.com/deploy/hugo-or-static-site-starter-built-by-a-d
---

# 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 on Railway](https://railway.com/template/hugo-or-static-site-starter-built-by-a-d)**

- **Creator:** Pavel Volkov's Projects
- **Category:** Blogs

## Template content

### hugo-railway-starter

- **Source:** ak40u/hugo-railway-starter
- **Public domain:** Yes

## Documentation

# Deploy and Host Hugo on Railway

A minimal [Hugo](https://gohugo.io) 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

- [Hugo documentation](https://gohugo.io/documentation/)
- [Caddy documentation](https://caddyserver.com/docs/)
- [Source repository](https://github.com/ak40u/hugo-railway-starter)

### 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`:

```dockerfile
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

```bash
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.

## Similar templates

- [Pixelfed](https://railway.com/deploy/OZSdEw) — Explore + Share beautiful photos and videos on the Fediverse
- [Hexo](https://railway.com/deploy/hexo) — Self-hosted Hexo blog with editor, comments, and S3 storage
- [NodeBB](https://railway.com/deploy/nodebb) — Node.js based forum software built for the modern web

Open this page in a browser: https://railway.com/deploy/hugo-or-static-site-starter-built-by-a-d
