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:

  1. I use firebase hosting
  2. it can provide convenient function to see site go live even in the PR stage
  3. the URL prefix changed
  4. 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.