Created
February 2, 2018 14:34
-
-
Save dudil/edf2b1838c7cc5f1131a3777dbc662a9 to your computer and use it in GitHub Desktop.
This is a hack to allow menu items with external links to be open in a new tab
Here is the equivalent for those modifying header.html (layouts/partials/header.html)
{{ with .Site.Menus.main}}
{{ range sort . }}
{{ $url := urls.Parse .URL }}
{{ $baseurl := urls.Parse $.Site.Params.Baseurl }}
<li class="navigation-item">
<a class="navigation-link" href="{{ .URL | relLangURL}}" {{ if ne $url.Host $baseurl.Host }}target="_blank" {{ end }}>{{ .Name }}</a>
</li>
{{ end }}
{{ end }}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This "hack" to the navbar.html file should allow open links that are menu items in new tabs while keeping local links behave the same.
This file should be saved under your own local hugo project layouts directory (if you don't have such a directory create it and put this file there).
This should override the theme default behaviour, until there is a stable solution from Hugo