Sam Hooke

Bind hugo to localhost for development

Situation: Want to run hugo on my laptop and access the website from my phone over wifi so that I can debug an issue that only occurs on my phone (issue does not occur in responsive mode using developer tools).

By default hugo binds to localhost which is only accessible internally (e.g. from on the same computer). Typically binding to will allow a server to be accessed externally (e.g. from another computer on the same network). However, just doing:

hugo --bind=

Does not completely work. Hugo will still use localhost to try and load resources (e.g. images, stylesheets).

The workaround is to use the --baseURL option, however unfortunately <IP> needs to be the IP address of your current machine (can’t just use so the solution is not portable:

hugo --bind= --baseURL=http://<IP>:1313

References §