Open external Link in Blank Page with Hugo

Markdown has limitations when it comes to fine-grained html, such as opening an external link in a new tab or window, but by combining markdown and hugo, you can get the best of both worlds.

We’re not going to mess with html or javascript here; it’s all about configuration.

Since the goldmark is the default markup rendering engine, you need to change that by switching to blackFriday, in your configuration file as the following

1
2
3
4
[markup]
    defaultMarkdownHandler = "blackFriday"
    [markup.blackFriday]
        hrefTargetBlank = true

From now on, any external link in your site will open in a blank page when clicked.

updatedupdated2024-01-172024-01-17