Hay,
I want to create a side menu in my baseof.html with some Links in it.
everything works EXCEPT, that all the Links are always relative to the active Page.
for example: If i set href="{{ .Site.BaseURL }}" i get baseURL/BaseURL as a link on my main Page, and baseURL/subpage/BaseURL on my subpage.
Sadly, this won’t work either. No matter what i put in for href, it will always be like “baseURL/CurrentPage/hrefinput”, instad of “baseURL/hrefinput” (or only href input).
Hay, thank you for your answer.
I Uploaded a “Stripped” version of my stuff: GitHub - Amsee-Daniel/MyTheme
The Only file that really contains stuff (And the problematic hrefs) is the baseof.html.
Ideally you need to generate the Page links list with the range function and within its context reference the respective .RelPermalink -as mentioned above by Bjørn Erik-.
With <li><a href="{{ .RelPermalink }}">Home</a></li> you are calling .RelPermalink without a relevant context. Therefore Hugo does not know what link to render and you are getting unpredictable output.
Go templates are context aware. You always need to use the link variables within a Page collection.
To generate a link to the Homepage either use:
<li><a href="/">Home</a></li>
OR
<li><a href="{{ .Site.BaseURL }}">Home</a></li>
P.S. There is no built-in variable to generate a link to the Homepage as far as I know.