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

前端 未结 3 1335
独厮守ぢ
独厮守ぢ 2021-01-31 06:54

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\", whi

相关标签:
3条回答
  • 2021-01-31 07:19

    The answer should be what @Idavid posted in a comment.

    [go](http://stackoverflow.com){:target="_blank"}.
    

    You should also add rel="noopener"

    [go](http://stackoverflow.com){:target="_blank" rel="noopener"}
    
    0 讨论(0)
  • 2021-01-31 07:27

    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.

    0 讨论(0)
  • 2021-01-31 07:33

    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.

    0 讨论(0)
提交回复
热议问题