Why put the scheme/hostname in baseURL?

I set up my site’s baseURL as directed, to “http://mysite.com/”. Worked great until I enabled HTTPS for my domain; but then accessing the domain as “https://mysite.com” results in a mangled page without CSS nor scripts, because those resources are still being loaded from “http://” URLs, and the browser (Safari) correctly blocks those loads as insecure.

I worked around this by changing the baseURL to:

baseurl = "/"

Works like a charm, and I can now view the page with or without HTTPS with no problems.

So now I’m wondering, why would one put the scheme/hostname in the baseURL? What benefit is there for identifying resources by full URLs instead of by paths? It just makes the page more fragile and slightly larger, and adds one more thing the developer has to manually set up before the site will work.

  1. Not everyone is building a Hugo site that starts at the root
  2. There are times where it is beneficial to write the entire URL (eg, with certain <meta>)

Thanks for the reply.

  1. The baseURL can be "/path/to/site/" for non-root sites.
  2. That makes sense. It might be beneficial to split baseURL into two parts, like baseDomain and basePath — then most things can use basePath, but those meta tags can concatenate the two.

Interesting ideas. Keep in mind you can always create site-wide params in your config.toml too… :relaxed: