Bind baseURL

I want to use Hugo on multiple PCs in my network so I use the command

hugo server --renderToDisk --bind 0.0.0.0 baserURL 192.168.0.142:1313

as advised in this post https://discourse.gohugo.io/t/binding-server-to-local-ip-or-0-0-0-0-does-not-work/18999/9

While it does work, all links revert back to localhost rendering this option useless. Am I doing something wrong?

baseURL in config.toml is set to “/”
hugo v0.82.0

The above does not look correct.

That does not look like a valid baseURL. You should set the baseURL in config.toml to your (most common) production URL.

seems to me this is the problem. try changing it to your production URL or maybe even to http://example.com/

And the flag is --baseURL not baserURL. Not sure if it’s a typo.

Otherwise, the command should work fine.

You are right in your observation, but the baseURL in config.toml is not used if it’s set as a flag.

right :sweat_smile:

what else could be the problem?

I suspect getting the flag syntax right should do it :slight_smile:

Thanks for your reactions and pointing out a typo, According to the docs, the right syntax should be

hugo server --renderToDisk baseURL http://192.168.0.142

I am a bit confused whether or not to add --bind 0.0.0.0 but either way the webserver is available at http://localhost:1313. Therefore {{ .Permalink }} in the HTML head still shows “http://localhost:1313/” making links on another PC useless.

Changing the baseURL in config.toml does not have any effect: {{ .Permalink }} shows “http://localhost:1313/

I use normally use flags as we use Netlify so it’s easy to configure development and production variables. Right now we are in development of this site so I just want to test features using our local network.

Where in the docs does it say the above? Because that is wrong and needs to be fixed.

Configure Hugo | Hugo states:

baseURL
Hostname (and path) to the root, e.g. https://bep.is/

Yes, but the baseURL flag needs to be prefixed with “–”.

Ouch, what a stupid mistake of me! It works beautifully now.
Apologies for wasting your time.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.