You are setting the --port that the local server will use.
The baseURL value is meant for project deployment, basically the baseURL is used to correctly output the permalinks of the various assets and pages.
I do not quite understand your setup.
It seems that you are trying to run the local server provided by Hugo, as a deployment server within a Kubernetes container. This is not my area of expertise.
Others may have more insights, hopefully they’ll share.
To clarify, I am running hugo on a container. The port hugo is using (and thus the container) is not equal to the port that is actually used to access the application. So the BaseURL should be different.
I don’t know a lot about Kubernetes, but I think your setup and problem is something like this:
you’re serving with hugo inside the container on port 8080
your container config maps inbound port 9301 -> port 8080
and so you’re trying to load a page by visiting http://localhost:9301 from the host machine, but all the links are broken because they’ve been rewritten to http://localhost:8080 by the port setting?
Is that right?
If that’s the case, it sounds like the CLI switches break the behaviour that you’re looking for. Is it possible to work around the issue by instead running hugo serve with --port 9301 and mapping 9301 -> 9301 in your container config?
Hi @capnfabs , that’s correct.
However i cannot use the same port since I’m running multiple instances of hugo containers, so they need separate ports. (so same container but different hugo config)
The following does not seem to have any effect: hugo serve --verbose --port=8080 --bind=0.0.0.0 --gc --source /site --config /site/config/dev.yaml --disableLiveReload --baseURL "http://localhost:9301/"
Otherwise, I took a quick look for the code that seems to be messing with the baseUrl. Have you seen the --appendPort option? It looks like setting --appendPort=false might do the trick. But, I think this solution is nastier and probably more prone to breakage in the future, because you seem to be pushing up against the edges of what hugo serve was intended for.
I wonder what a better UX here would be though; I think keeping hugo serve fiddling with the port is really useful for the general use case, but you’re right that it’s extremely confusing in this (somewhat rarer) combination.