New Jekyll Plugin for Link Attributes


Our website uses Jekyll, a static site framework. I chose Jekyll to help us manage a large amount of content. Managing all of our site content in a code repository means we can manipulate all sorts of things with a little bit of code.
One thing I've wanted to do is ensure that all of our external links default to having reasonable attributes.
For example, all of our external links have a rel="noopener"
attribute to prevent tabnabbing.
I also wanted to add a target="_blank"
attribute so external links open in a new tab instead of sending visitors away from our site.
Adding the attributes to every link on the site was cumbersome, and we would miss some links sometimes. Though my primary goal was to increase consistency across all of our pages, proper link attributes also offer some minor SEO benefits.
I found a Jekyll plugin that would do most of what I wanted, but it was not compatible with the latest Jekyll version. Instead of settling for a partial solution and trying to make it work with our site, I decided to create a new plugin.
The jekyll-link-attributes plugin automatically adds your desired rel
and target
attributes to all external links on your site.
This happens during the build process, ensuring we catch every external link every time.
The plugin's default configuration is a good place to start, but it is easy to customize your link attributes.
You can add any rel
or target
attribute you like and exclude links that you don't want to modify.
If you use Jekyll, give it a try!
Subscribe to my newsletter
Read articles from Twin Sun directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Twin Sun
Twin Sun
Every successful project starts with trust. We make this concept evident from the start of every new relationship. Before we write the first line of code, we will seek to understand you and your team as human beings. We start each partnership by building a foundation of mutual trust and respect. We'll ask about your business, your goals, and what you envision when you think of your future product. This ensures we are aligned on how to build your product and give you the best possible outcomes based on our understanding of your business. Based in Nashville and founded in 2017, Twin Sun set out to bring humanity to software development consulting. We understand the challenges you face when selecting a development partner. We've worked with teams of all sizes, from one-person startups to global corporations, and we are ready to help navigate all aspects of product design, development, and long-term support to help make your effort as successful as possible.