Then I want to make this clearer in the docs.
Here’s why, for anyone interested:
In a template for a site with a configured baseurl = "http://mysite.com"
, running locally the following will work…
<link rel="stylesheet" href="{{.Site.BaseURL}}css/style.css">
Because, at least from what I remember a couple versions ago, the local server includes the trailing slash, as follows:
<link rel="stylesheet" href="http://localhost:1313/css/style.css">
However, using the example http://mysite.com
(or even leaving the baseurl
field empty [baseurl = ""
]) in the config
would create the following at build:
<link rel="stylesheet" href="http://mysite.comcss/style.css">
Which breaks for obvious reasons. As I mentioned already, using relURL
and absURL
functions are a best practice, especially in the context of themes, but I’d like to make this clearer in the docs.
I don’t feel like I’ve seen this a lot lately, but there was certainly confusion about it in the past and in my own experience starting Hugo…if my memory serves.