Jekyll External Link Accessibility
This plugin makes every link in your blog posts open in a new tab accessibly (target, title, a new-tab icon, and a screen-reader note), and adds rel="nofollow" to external links.
Setup
- Add the gem to your
Gemfile:gem 'jekyll-external-link-accessibility' - Run
bundle installto install the gem - Add the following to your
_config.yml:plugins: - jekyll-external-link-accessibility
Usage
The plugin edits every link in a post, internal and external:
- All links open in a new tab so readers don't lose their place, with a
title, a new-tab icon, and a screen-reader-only "opens a new window" note. Skip a specific link by addingdata-no-external="true", e.g.<a href="...." data-no-external="true">...</a>. - External links (pointing to a host other than your site's
urlin_config.yml) also get arelattribute (external nofollow noopener noreferrerby default, see Configuration). Thenofollowkeeps them from passing your link equity off-site, so internal links are left without arel. Thewww.prefix and host casing are ignored when comparing hosts.
Configuration
You can override the default configuration by adding the following section to your Jekyll site's _config.yml:
external_links:
rel: external nofollow noopener noreferrer
target: _blank
title: Opens a new window
Styling
Next to each link is a new-tab icon with a icon-external-link class name. You need to have the styles in your project. For example, we use icomoon for icons:
.icon-external-link:before {
content: "\ea7e";
}
Default Configuration
| Key | Default Value | Description |
|---|---|---|
external_links.rel |
external nofollow noopener noreferrer |
The rel attribute to add to external links. |
external_links.target |
_blank |
The target attribute to add to external links. |
external_links.title |
Opens a new window |
The title attribute to add title to links. |
Steps to release a new version
We follow Semantic Versioning: bump MAJOR for incompatible changes, MINOR for backwards-compatible features, and PATCH for backwards-compatible bug fixes.
- Update the version in
lib/jekyll-external-link-accessibility/version.rb - Update
CHANGELOG.md: move themain (unreleased)entries under a newvX.Y.Z / YYYY-MM-DDheader - Push a
release/vX.Y.Zbranch with those changes - Open a pull request titled "Release vX.Y.Z" and merge it to
main - Tag the release and push the tag:
git checkout main && git pull git tag vX.Y.Z git push --tags - Build the gem:
gem build jekyll-external-link-accessibility.gemspec - Push it to RubyGems:
gem push jekyll-external-link-accessibility-X.Y.Z.gem