How to make a markdown link open in another tab

Sometimes it's important you do not break a reader's flow by redirecting them away from your markdown document when they click on a link. In this case, it's better for such links to open up in a different tab in their browser, unfortunately, the commonMark document which is a specification for the Markdown syntax does not describe a way to implement this.

This means different systems adopt different syntax or ways to enable this.

Using Anchor tags

Most markdown parsers will allow HTML to co-exist with markdown without escaping the HTML. This means if you write or add any HTML in your markdown it will show up when it's finally rendered. This allows you to use the HTML anchor tag when you need to add an external link instead of the []() syntax in markdown. You just add the target="_blank" attribute to your anchor tag so the links open up in a different browser tab.

01:     <a href="" target="_blank">Opens in new tab</a>

The only downside to this is that your markdown document is no longer purely markdown as it contains HTML. This may or may not be a problem depending on your use case.

Alternative approach

I thought to myself, how do I add external links without adding special syntax to my markdown parser or adding HTML to my documents?

The solution that came to mind was to have the user be redirected to a different page that then goes ahead to open up the clicked link in a different tab and then redirects the user back to their last reading position.

Putting it all together I ended up creating All you have to do is append your link to the URL and reference it in your markdown and it takes over from there.

01: [Opens in new tab](

In fact, all links in this article use this implementation. It is also open source so feel free to clone and run your copy if you want to. It's pretty easy to host as it's just HTML, CSS, and Javascript.

Here is another article for you 😊 "5 terms to know as a technical writer [part 1]"