<a href="{{ .Destination | safeURL }}"{{ if ne true (in (urls.Parse .Destination).Host (urls.Parse .Site.BaseURL).Host) }} target="_blank"{{ end }}>{{ .Text }}</a>
Notice: from a UX point of view, it is not really recommended to force external links to open in new tabs. You may add an “external link” icon after the link text instead.
I created a PR in case one wants to include this example in the docs.
But links like [a link](http://mydomain.com/blog) will be treated as external, no? That’s why I chose (urls.Parse .Destination).Host, to be sure to treat links correctly even if the content editor puts a “full” internal URL. Bep’s code assume that all internal links are written without “http” in front of them, right?