Append target="_blank" and ref="nofollow" to all links

Hello,

I have a lot of articles in markdown that is being generated upon middleman deployment. It’s a hassle to manually add {:target="_blank" rel="nofollow"} at the end of each link within the text.

I am looking for way to automatically append that part to all the links, unless I exclusively change it manually.

So for example, by default, all links will have {:target="_blank" rel="nofollow"} but if I want to, I can manually declare in markdown for particular link to dofollow the link.

How can I achieve it?

Take a look at https://kramdown.gettalong.org/syntax.html#attribute-list-definitions If I correctly understand, this should do.

Hey,

I don’t think this is a solution to my issue. I want to be able to automatically add {:target="_blank" rel="nofollow"} to each link on my website, unless I override it manually with other attribute.

I managed to solve first part where extra link attributes are inserted across all links on the site by adding in config.rb:

set :markdown_engine, :redcarpet
set :markdown, 
  :link_attributes => { target: '_blank' }

However, now I am not able to manually add anything at the ned of my link like I used to: {:target="_blank" rel="nofollow"}.

So for those links I want to remove attribute rel="nofollow" I will need to define them in markdown with injecting it as HTML link like <a href="my url here">my link here</a>.

Would love to know a better solution :slight_smile: