Alex V
Alex V

Reputation: 3644

How do I customize how markdown links are rendered in Jekyll?

Jekyll's markdown can cause a link to be opened in a new tab like so:

[External link](https://rubygems.org/gems/jekyll-target-blank){:target="_blank"}

This however creates an opening for reverse tabnabbing, which could be prevented by adding additional attributes. However, some markdown writers may forget to do so, leaving an easy way for accidentally reverse tabnabbable links to sneak it.

I want to prevent this by making all links carry the ref='noopener' property.Perhaps this can be done with Jekyll's default rendered, Kramdown. Reading the docs, I don't see any obvious way. Or maybe I need to switch to Redcarpet?

Upvotes: 0

Views: 116

Answers (1)

Alex V
Alex V

Reputation: 3644

I just found an easy way to do this with the Gem jekyll-target-blank. It adds noopener by default.

https://keith-mifsud.me/projects/jekyll-target-blank

Upvotes: 1

Related Questions