Markdown and Jekyll are great aren’t they… but there are a few issues which crop up from time to time, like how do you add attributes to anchor tags (or other Markdown converted HTML elements for that matter) in Jekyll? Alas, it’s not something that’s actually possible in Markdown. Though thankfully Jekyll uses a superset of Markdown called Kramdown, in which it is possible to add attributes. So you can add things like a class, target or rel (relationship) attributes with ease, and it works as follows:

[text](link){:attributes}

This is not something which is documented particularly well, in-fact it is not documented at all on the Jekyll site. It is only by exploring the Kramdown documentation that you will discover what you need to do. There are numerous ways this is useful, for example you could open a link in a new window (or tab):

[Megalomaniac's Lair](https://megalomaniacslair.co.uk/){:target="_blank"}

Or you could add a class to your link:

[Megalomaniac's Lair](https://megalomaniacslair.co.uk/){:class="myclass"}

You may also add useful search engine related tidbits like the nofollow relationship:

[Megalomaniac's Lair](https://megalomaniacslair.co.uk/){:rel='nofollow'}

And, of course, you can stack them together:

[Megalomaniac's Lair](https://megalomaniacslair.co.uk/){:class="myclass" target="_blank" rel="nofollow"}

Which produces the following HTML:

<a href="https://megalomaniacslair.co.uk/" class="myclass" target="_blank" rel="nofollow">Megalomaniac’s Lair</a>

And there you have it: adding attributes to links in Jekyll, easy when you know how!