Excluding port from sitemap baseurl

I’m using hugo server -b http://baseurl.com/ as a command to serve my hugo site as a service on linux (I know this isn’t recommended but hey, it’s working). localhost:1313 is reverse proxy’d behind nginx. Visitors go to http://baseurl.com and yay it works.

The issue is, in my sitemap, the urls are all http://baseurl.com:1313/. I… don’t want the port there, and I don’t want to have to change my port just for this issue.

  1. Is there a flag for server that exists as is to get around this?
  2. Is there a quick edit I can make to the sitemap generator or some variable to avoid this?

See the -p option

I am aware that I can change the port, but given that I have it successfully reverse-proxied, I would prefer to not have to specify a different port just because the sitemap (and literally nothing else) is incorrect.

I have a feeling that, if you decide to try to run hugo server in production, all of these various scenarios that are possible are not fully tested, despite the “Many run it in production” statement. Probably better to just use hugo to build to a folder, then host the built site’s folder with a bespoke web server.

I suppose you could search around in here and build a custom sitemap template. I imagine it would have to be somewhat hard coded. Not sure, as I haven’t tried this setup.

1 Like

Have you tried setting —appendPort to false ?


I think --appendPort might be what I was looking for but my eyes just kept glancing past it

Nope, --appendPort was not the answer, which is a little worrying. It’s looking more and more like the issue is with decisions made in the realm of sitemap generation specifically.

I’m a liar! that was it. Thanks everyone.

TIL about --appendPort. Nice catch.