Confusion with baseURL

Thanks for that, it makes a lot of sense.

Hugo seems to override the domain and port part of baseURL and replace that with localhost:1313 (by default). As you say, if you build the site (just run hugo) and look in public, you’ll find the html files have been properly expanded.

I found that I was making a really stupid mistake as well, I was referring to the config baseURL in my templates as .Site.Params.baseURL, instead of .Site.BaseURL. The former is always blank (unless there is a .baseURL in the [params] block) - I tried it with .Site.Params.reallyNotHere and got a blank - no build error, just blank, whilst the latter is the value of the baseURL config parameter.

Because I was deploying the site at the root level, I never saw this issue.

Now, I have some find-and-replace to do…

The case-ness of the config parameters still confuses me though; for parameters in a [params] block, the case of the parameter seems to be ignored in the config and template. For parameters at the top level (eg our friend baseURL), the case in the config file seems irrelevant, but when they are accessed in templates they are very much case-dependent. The configuration documentation has a long list of configuration options, but it’s not obvious how they should be referred to in templates. I suppose that’s for another day…

Thanks again for the clarification, it’s very helpful.

1 Like