Adding Tags
A new feature!
If you scroll to the bottom of this post you’ll see something new… Tags! They’ve been part of the posts’ metadata all along, but since tags weren’t visible on the page they were more mostly a signpost to myself, something to build on top of. And now I have!
I had a short list of features I knew that I wanted:
- An easy way to list all tags for a post
- Generate a page for each tag automatically
- An alphabetical listing of tags Other than that I just wanted to keep things as simple as possible.
I knew beforehand that Jekyll had some support for tags built-in – adding tags as an array in the Jekyll front matter is how I’m putting them in the metadata, but tag pages aren’t part of the stock generator. Before deciding to roll something myself, I did a bit of searching for plugins. I saw a couple mentions of jekyll-tagging which sounded promising. It seemed to basically be able to do what I wanted, it seemed pretty simple, and it didn’t seem like it was trying to do too many additional things I wasn’t interested in. Perfect!
…until I noticed that the repo on GitHub hasn’t been updated in seven years. Oof, not maintained. Not great, but also, one of the things I like about using static site generators is that, relatively speaking, they can be pretty straight forward. Maybe it would be okay that this plugin isn’t maintained? The README install instructions were explicit, even if they didn’t exacly match my (limited) experience installing Jekyll plugins. “If it’s easy and works, I’ll use it,” I told myself, “and if not, I won’t have spent too much time trying to coax it through seven years of bitrot.” I did get it working and I only ran into a couple of hiccups, one of which had a solution waiting for me in a helpful open issue on the repo’s tracker.
Hiccup 1 - Dependency Error: Yikes! It looks like you don't have jekyll tagging
The README doesn’t specify how to add the plugin in _config.yml, and if you make the assumption that you add it as jekyll-tagging
, as I did, you will run into this error. Apparently it needs to be added as jekyll/tagging
, as explained in this open issue.
Hiccup 2 - Adding _plugins/ext.rb
The instructions called for adding to _plugins/ext.rb
, a file and folder that do not exist in my admittedly very basic site. I did a quick and unscientific survey of plugins on GitHub and none of them mentioned _plugins/ext.rb
, either, but things Did Not Work when I skipped this step, so I added the directory and a file with just the one line required for jekyll-tagging
. That did the trick. My guess is that this is how older plugins were registered or something like that?