How do I make "some" menu entries open in a new tab?

Hey guys,

I’d like to be able to make some of the menu entries open in a new tab. This doesn’t seem to be possible by design, but I was hoping that maybe someone found a workaround. There are some issues on GitHub about this but I couldn’t see any solution.

I know it can be done by editing the HTML files and adding target attributes to links after the site is generated, but this is not ideal. I’d have to do it every time I update the site and for each page I have. So I’m looking for something that can be implemented on Hugo directly.

I appreciate the help!

welcome,

search for the partial generating the navigation element, should be under layouts/partials and mostly named navigation.html.

Add the target to <a href={{.RelPermalink}} target=_blank ...

If you have any criteria to decide when to add, use a {{if ..} {{else}} {{end}} construction.

edit: figured what the problem was with my code! This was the solution, thank you very much! @ju52

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.