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
bep
April 28, 2021, 9:00am
2
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.
bep
April 28, 2021, 10:21am
4
You are right in your observation, but the baseURL
in config.toml
is not used if it’s set as a flag.
right
what else could be the problem?
bep
April 28, 2021, 10:40am
6
I suspect getting the flag syntax right should do it
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.
bep
April 29, 2021, 11:22am
8
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/
bep
April 29, 2021, 11:54am
10
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.
system
Closed
May 1, 2021, 12:11pm
12
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.