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="placeholder.com" 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.
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 https://external.ink. 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](https://external.ink?to=/placeholder.com)
And that's it! If you enjoyed this post please be sure to join my newsletter as I post new content like this from time to time :)