Aral Balkan

Mastodon icon RSS feed icon

Override BaseURL in Hugo Server

Hugo has a baseURL setting in its configuration file (config.toml) that is used when creating absolute URLs. Sadly, this setting is ignored if you’re running Hugo with:

hugo server

I use relative URLs in all of my posts and templates but I got bitten by this with the generated RSS feed. All the URLs were being written with localhost:1313 prefixes.

To work around this issue, start Hugo using the --baseURL and --appendPort flags to override the default settings. e.g. I start a live session on this blog with:

hugo server -D --renderToDisk --baseURL=https://ar.al --appendPort=false