Why is Hugo server doing HTTP redirects?

I’m running Hugo in server mode for editing my site:

hugo server --watch

Hugo is not behaving like a static site’s plain http server might. For example if I type in


into my browser’s address bar, Hugo is doing a redirect. Here’s what curl outputs:

$ curl -v http://localhost:1313/index.html
* Hostname was NOT found in DNS cache
*   Trying ::1...
* Connected to localhost (::1) port 1313 (#0)
> GET /index.html HTTP/1.1
> User-Agent: curl/7.37.1
> Host: localhost:1313
> Accept: */*
< HTTP/1.1 301 Moved Permanently
< Location: ./
< Date: Sun, 08 Mar 2015 18:44:24 GMT
< Content-Length: 0
< Content-Type: text/plain; charset=utf-8

That isn’t how my web server behaves; it lets me view the index.html (which does exist, of course, and has content). I think Hugo is being too smart here, but perhaps there is a reason for this?

1 Like

Hi @xaprb,

Very “interesting” behaviour indeed! But a quick look in hugo/commands/server.go did not show anything “interesting”, hinting that it is Go’s own net/http “normal” behaviour, which led me to this:

And the code is a few lines from the top of serveFile() here: http://golang.org/src/net/http/fs.go#L342


1 Like