Today I Learned ...

... How Hugo Server Treats The BaseURL setting

I was just wondering why my RSS URLs don’t work in the deployed version of this site. All Feed Links were pointing to localhost:1313 instead of the baseURL set in my hugo.toml configuration file.

Turns out hugo server ignores the baseURL setting. The reason, I assume, is that hugo server is used as a dev server and you shouldn’t have to point your configuration to localhost while developing and then switching to the live URL when deploying.

The solution was to start hugo with two options:

hugo server --baseURL=https://example.com --appendPort=false

The first option obviously sets the live url. The second option keeps hugo from appending the default port (1313) to the URLs.

So, you might wonder: Why does this only affect RSS? Technically, it does affect all URLS, but most URLs in Hugo are relative by default, so they don’t use the baseURL setting. Absolute URLs would also use localhost.

Tags: