Hugo: open external links in a new tab


Create a file layouts/_default/_markup/render-link.html:

<a href="{{ .Destination | safeURL }}"{{ with .Title}} title="{{ . }}"{{ end }}{{ if strings.HasPrefix .Destination "http" }} target="_blank" rel="nofollow noopener noreferrer" {{ end }}>{{ .Text  | safeHTML }}</a>

Done!

Source: Inspired by Elliot Sachs.


Tags:


Comments: