Bind hugo to localhost for development
All notes in this series:
- Automating hugo development with npm scripts
- normalize-scss with hugo
- Automatic image thumbnails in Hugo from static directory
- Escaping Hugo shortcodes within Hugo markdown
- Hugo tag and category pages
- Bind hugo to localhost for development
- Hugo 0.37 does not support h6 markdown heading
- Install Hugo testing distribution on Debian
- Hugo anchors next to headers
- Hugo: Migrating from Pygments to Chroma
- Hugo: Global resources
- Hugo: How to create a post series
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 0.0.0.0
will allow a server to be accessed externally (e.g. from another computer on the same network). However, just doing:
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 0.0.0.0
) so the solution is not portable: