Inside the navigation I would like to insert a link back to ‘home’ if the current url doesn’t equal ‘home’. My template code looks if the .Permalink
of the current page is not equal to the .Site.BaseURL
.
{{ if ne .Permalink .Site.BaseURL }}
<a href='{{ .Site.BaseURL }}'> <span class="arrow">←</span>Home</a>
{{ end }}
<h1>{{ .Site.BaseURL }}</h1>
<h1>{{ .Permalink }}</h1>
Furthermore I printed both URLs for each page inside the navigation. The problem is that the link is shown in every template including home.
The weird thing is that both URLs are the same at home, as the output below shows.
http://localhost:1313/
http://localhost:1313/
Therefore the link to home should not be printed in the navigation.