keithmifsud / jekyll-target-blank

Automatically opens external links in a new browser for Jekyll Pages, Posts and Docs.
MIT License
105 stars 19 forks source link

Add rel attribute with noopener to all links with target=_blank #34

Closed skrings closed 5 years ago

skrings commented 5 years ago

Thanks for the handy plugin 👍

If would love to have a feature where I am able to configure that the attribute rel="noopener noreferrer" should be added to all links with target="blank". So my goal is to add the rel attribute where needed and not to specify the target attribute for all external link.

This way you are able to control which links are opened in a new tab and these links are secured automatically because the plugin adds the rel attribute with the configured values.

keithmifsud commented 5 years ago

You're welcome @skrings :smile:

I'm not sure I understood the question.

You can configure the plugin to only add the target attribute to links which have a certain CSS class name. You can also which rel attribute values to add if you don't want the default.

Have your read the README file? https://github.com/keithmifsud/jekyll-target-blank

skrings commented 5 years ago

Hey @keithmifsud

My goal is to add rel=noopener attribute to all external links in order to secure these links.

For this I am missing a feature where the plugin selects all anchor tags by the presence of target="_blank" attribute and adds rel=noopener attribute (with the configured values).

If I configure a certain CSS class all anchor tags with this CSS class will get the attributes target="_blank" and rel=noopener. But potentially there are anchor tags without the CSS class but with target="_blank".

skrings commented 5 years ago

It seems like this plugin https://github.com/d-ogarkov/jekyll-extlinks is exactly doing what I want.

keithmifsud commented 5 years ago

Thanks for letting me know. I believe that JekyllTargetBlank already features your requirements. rel attributes are added automatically to all external links (links outside your site's domain). You can also specify other rel values in _config.

Please let me know if I'm missing anything, however, I am glad that you have found another plugin which may be more suited to your use case :)