Opening a menu in a new tab


I’d like to open a menu item on a new tab.

As I understood, the blackfriday option hrefTargetBlank allows opening absolute links in a new tab.

I activated it by adding the following line to the site configuration:

  hrefTargetBlank = true

In the same config file I have a menu:

    identifier = "id1"
    name = "name 1"
    url = "/name1.html"
    weight = 1
    identifier = "id2"
    name = "name 2"
    url = ""
    weight = 2

In this case, should open in a new tab, right?

This is the code of the menu:

      <nav class="nav nav-navbar  ">
      {{ $currentPage := . }}
      {{ $baseurl := urls.Parse $.Site.Params.Baseurl }}
      {{ range .Site.Menus.navbar }}
      <a class="nav-link  {{if or ($currentPage.IsMenuCurrent "navbar" .) ($currentPage.HasMenuCurrent "navbar" .) }} active{{end}}" href="{{ .URL }}" title="{{ .Title }}">{{ .Name }}</a>
      {{ end }}

This is Hugo BF conf:

    hugo config|grep -i black
    blackfriday = map[hreftargetblank:true]

The external website is not opening in a new tab.
Am I missing something ?

I would handle this in your template code. Add this attribute to your anchor element:


Thanks. Can you please share more details about this ? I didn’t really understand.

MDN explains it better than I can. Under the “attributes” section, read about “target”

Oh, I thought you were speaking about shortcodes or something like this.
Thanks for the link, but I don’t want to handle this using HTML.
My question was about handling this using Hugo and “hreftargetblank:true” configuration

Right. Your markdown gets rendered to html at the end of the day. So to me it’s a matter of preference.