Closed RickCogley closed 7 years ago
It should be consistent. But manually creating URLs using {{ .Site.BaseURL }}
is fragile, esp. for themes, and not recommended.
Use absURL
and friends, and you should not have to worry about slashes.
thanks @bep, I'll give it a try!
@bep as you say, that works perfectly.
For future reference for searchers, doing:
<img src="{{ "img/mylogo.jpg" | relURL }}" class="this that" alt="Logo">
... for the http://anothersite.com/~myuser
site, gives:
<img src="/~myuser/img/mylogo.jpg" class="this that" alt="Logo">
... and for the http://www.mysite.com
site, gives:
<img src="/img/mylogo.jpg" class="this that" alt="Logo">
Thanks again!
This change is a bug fix and it also will break configurations that relied inadvertently on the old buggy code. It's a one-byte fix if you need the trailing slash. If you need it and don't use it, you'll get this behavior:
https://discuss.gohugo.io/t/hugo-0-20-upgrade-page-template-breaks/6097
https://github.com/vjeantet/hugo-theme-casper/issues/84 notes changes suggested to the Casper theme for 0.20.
Casper theme has been updated with changes.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Hello - it's been a while.
If I set a baseURL in my config.toml, such as http://www.mysite.com, when I use
{{ .Site.BaseURL }}
, no trailing slash is appended, so I'd compensate by adding one in the template.Then, say if I want to publish the same content to http://anothersite.com/~myuser, I can override the baseURL in the
hugo
command when I generate like:...but, when doing this, it appends a trailing slash, so I don't need to compensate.
Should this not be consistent?
Using: Hugo Static Site Generator v0.20-DEV-73C1C7B6 darwin/amd64 BuildDate: 2017-04-02T16:28:29+09:00