Jekyll – use includes directly from plugins

Jekyll is a popular static site generator that I’m using to develop the new Decipher SciFi site. It’s pretty sweet.


Normally, Jekyll’s include tag can only search for files in the site’s single configured includes directory (and that of the theme plugin, if it using one). That means that if a plugin wants to provide you with a template/fragment via includes, the best it can do is ask you to copy it into your own repo manually. That sucks.

So I wrote jekyll-plugin-include: a gem-based Jekyll liquid tag plugin which allows includes directly from plugins’ _include directories, with optional ability to override with files present in site includes_dir (if they exist).

This plugin then makes it easy to use includes that ship with a plugin directly from a plugin. And if a modified version of the file is provided in the site’s own includes directory, it can intelligently use that one instead!

And for plugin developers, this provides a way to ship and use includes without leaning on the user to manage the unmodified files themselves.