How can I set the rel attribute on links?

I’ve read through the Goldmark documentation and I’m surprised to find that apparently specifying the rel attribute is not supported for links. Will I really need to write a custom shortcode/use raw HTML for setting rel=nofollow or rel=external? (In particular, I’d like to set rel=external and then style these links differently.) Along with needing the relref shortcode for internal pages, that seems like I’d never actually use native Markdown linking.

Currently you can set the rel attribute from the template by performing a search and replace of the .Content variable with: the replaceRE function, or by using Hugo shortcodes in content files (the latter is easier to do).

However once the following issue is resolved then setting the rel attribute may be possible from a dedicated template (this feature is scheduled for the next release):


Hi @InhumanStraitjacket. Welcome to the Hugo forums. Here’s the code snippet I use for adding rel attributes to external links. You can use it to treat your external links with a little CSS like so inside a Custom Shortcode so all of your links will work the same site-wide.