On Hugo 0.15 with the hrefTargetBlank BlackFriday option enabled, relative links made with the Hugo relref are also opened in the another tab. For example:
- [Colours sorted by hue]({{< relref "#colours-sorted-by-hue" >}})
Generates the following HTML code:
<ul>
<li><a href="#colours-sorted-by-hue" target="_blank">Colours sorted by hue</a></li>
</ul>
Is this expected behaviour? It seems to me that relative links should not have the target="_blank" section added to it.
<ul>
<li><a href="#colours-sorted-by-hue">Colours sorted by hue</a></li>
</ul>
So it doesn’t seem to be because of the # sign.
It might be separate from BlackFriday’s hrefTargetBlank option because ref and relref also work differently than documented. The docs say the difference between them is a relative vs. absolute link, but that’s not what I see on Hugo 0.15.
@Jura This is part of a Hugo Starter I’m trying to put together (mostly to teach myself), but maybe (strong maybe) this might help you so that you don’t need to fiddle with the simple content of the MD file?
No I haven’t. I perhaps should, but didn’t want to open an issue too soon without the ‘green light’ from a Hugo contributor or confirmation from another person. But if you experience the same behaviour it’s probably a bug.
I’m Anna and I’m quite new in hugo and I’ve found this topic 'cause I was looking for a solution for target="_blank" in .md for my blog.
I’ve found that @dimo414 solution was perfect (thanks!) for me.
But I’ve tried to use this shortcode for an internal link and this can’t work: my blog is not currently online so I’ve not a “real” link. At the moment I’m using [post](/blog/aaaa/mm/dd/post) for internal link…
Should I use html metod and forgive about this shortcode? Or… Can I edit it?
Thank you very much!
Sadly, shortcode ref/relref link can no longer be used as the link will be generated with target='_blank' as well.
You can use markdown reference link.
[External link with _target blank](http://www.google.com)
[Internal Page](/posts/my-page/)
[Internal Page using reference][my-page]
[my-page]: /posts/my-page/