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
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
target attribute you like and exclude links that you don’t want to modify. If you use Jekyll, give it a try!