No release in over a year
This plugin replaces any occurence of glossary entries in pages and documents with a hyperlink to the associated glossary entry. For this to work the glossary needs to be a collection where each glossary entries is defined over its title.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 3.7
 Project Readme

Jekyll Hyperlinkify Glossary

A Jekyll gem to replace glossary entries in html with hyperlinks

Gem Version

This plugin replaces any occurence of glossary entries in pages and documents with a hyperlink to the associated glossary entry. For this to work the glossary needs to be a collection where each glossary entries is defined over its title.

Usage

Add the gem to your site's Gemfile

gem 'jekyll-hyperlinkify-glossary'

To use the gem a glossary needs to be created as collection _config.yml

collections:
  glossary:
    output: true

The gem will now check all pages and documents against the glossary entries. For this the content of a page is compared against the glossary entry title. In addition the synonyms can be added to the frontmatter. Example of usage:

title: test
synonyms:
    - analysis
    - evaluation
    - inspection

Configuration

A page can be excluded from the gem by adding jekyll-hyperlink-glossary to the frontmatter.

jekyll-hyperlink-glossary: false

Setting a different base url for the Hyperlinks

Normaly the plugin creates a Hyperlink with just the permanentlink from the glossary entry. This can be problematic when the glossary is part of a subsite. If this is the case a specific base url for the plugin can be added to the config which will be added before each glossary entry url. It is important to not have a tailing /

hyperlinkify_glossary_base_url: /subsite/test

How does it work?

A hook is applied to all pages and documents in the post rendering step and does filter everything in the html body with a regex against the glossary entries. This regex does ignore the html tag for headings (e.g. <h1>) and links (e.g. <a>).

As custom collections are not accesible during the post rendering step a second hook aggregates in the post read step the glossary and adds it to every page in the form of a 2-dimensional array. This array does contain one entry for every glossary entry. Each of these entries is an array of the link to the glossary entry, the title and all added synonyms.