Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

open link in new tab with github markdown using target="_blank"

Is there a way to let a Link, written in githubs markdown, open in a new tab? All posts I have found related to this suggests to use HTML and target="_blank", which is fine with me, but that doesn't work. For example this link:

<a href="http://stackoverflow.com" target="_blank">Go</a>

Does not open in a new tab. I'm no interested in replies for all kind of different markdown syntaxes, but only in a solution that will work when I write my markdown on github.

like image 651
Plaul Avatar asked Jan 28 '17 22:01

Plaul


People also ask

How do I make a link open in a new tab in markdown?

Albert Kim just discovered one way to make links open in new browser tabs for R Markdown users: you can add an attribute target="_blank" after a link, e.g., [example website](https://example.com){target="_blank"} .

How do I make a link open in a new tab in GitHub?

How do I make a link open in a new tab in markdown? You just add the target="_blank" attribute to your anchor tag so the links open up in a different browser tab.

How do I add links to GitHub markdown?

Links. You can create an inline link by wrapping link text in brackets [ ] , and then wrapping the URL in parentheses ( ) . You can also use the keyboard shortcut Command + K to create a link.


2 Answers

Well it seems that the simple answer is "It's not possible". Github does not include the target attribute even if you use plain HTML, so it's not a in the final HTML Anchor tag. Annoying, but OK, users can just do a CTRL+click (on Windows and Linux) or CMD+click (on MacOS) on the link, the get the same behavior.

like image 118
Plaul Avatar answered Sep 19 '22 21:09

Plaul


There is a solution specific to websites using GitHub pages: adding line

markdown: kramdown

to file _config.yml, you can use [go](http://stackoverflow.com){:target="_blank" rel="noopener"} because then GitHub pages engine uses another markdown called kramdown for generating html. However, it does not work on previews and in markdown rendered by GitHub directly in the project repository.

like image 24
dpolivaev Avatar answered Sep 20 '22 21:09

dpolivaev