Fix Hugo URL open problem
I use hugo for my staic website.
however, while writing docs, a queer problem happened: the url print in console is always broken.
Web Server is available at //localhost:1313/ (bind address 127.0.0.1)
I download the source code and start debugging. I use an example site freshed generated by hugo compared to my own site.
turned out that I didn’t set the baseURL
in my configuration.
However, after set it, another problem happened:
- I use firebase hosting
- it can provide convenient function to see site go live even in the PR stage
- the URL prefix changed
- all the following links points to old URL!
So I have to fix it by creating a fork.
The result is as follows:
https://github.com/soda92/hugo/pull/1/files
url := serverURL
if !strings.HasPrefix(url, "http") {
url = "http:" + url
}
c.r.Printf("Web Server is available at %s (bind address %s) %s\n", url, c.serverInterface, roots[i])
build
build part is easy. just run:
go build -tags extended .
then copy hugo.exe
to a bin dir in $Env:PATH
.