Adding attributes to links in Jekyll

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):