On my site I have relativeurls = true
. This meant, when creating the menu.main
items, a link based on the user’s current position would be generated.
For instance if I have
[[menu.main]]
name = "A place to go"
url = "/categories/place"
The link would be appear as ./categories/place
in the navbar depending on where I am. In those simple times, my nav.html
looked like this
{{ range .Site.Menus.main }}
<li><a href="{{ .URL }}">{{ .Name }}</a></li>
{{ end }}
Due to some changes I introduced, it became more practical for me to replace the link with a
{{ partial "menu.main.html" .}}
and create a menu.main.html
partial by doing
<li>
{{ with .URL }}
<a href = {{.}}>
{{ end }}
{{ .Name }}
{{ with .URL }}
</a>
{{ end }}
</li>
from inside the menu.main.html
However this caused the link to be created as
/categories/place
instead of a relative link.
In fact, I can change the nav.html
into something like
{{ range .Site.Menus.main }}
<li><a href="{{ .URL }}">{{ .Name }}</a></li>
{{ partial "menu.main.html" .}}
{{ end }}
and can see both versions appear side by side, one correct and the other incorrect while I would expect identical behaviour from both cases
Can someone explain me what is going wrong here? The old version of the repository is available here Slightly different than this example as I tried to simplify the code and doesn’t have the menu.main.html
.