A collection of higher-level {% include %}-able Liquid functions for GitHub Pages

Go to GitHub Jekyll Liquid

When working with GitHub Pages/Jekyll for the first time, I was struck by the lack of some slightly more complex functions in Liquid. So I wrote some files that could easily be included into a larger website to provide additional functionality.

The implementation of these functions take advantage of Liquid's {% include %} and {% capture %} tags to pass parameters and capture return values. Unfortunately, {% capture %} is only able to deal with strings, so lists must be returned as seperator-delimited lists.

Because {% capture %} is used as the mechanism to return values, the functions must have all extraneous whitespace stripped away. Therefore, each script has two version: the source code and the "minified" version with all extra whitespace stripped.

A more technical documentation may be found here. What follows is simply an overview of available functions.


min.lqf is a simple 2-argument minimum function.

max.lqf is a simple 2-argument maximum function.

array-remove.lqf is a file that takes an seperator-delimited list and removes the first element of the list. This simple function was missing from the available Liquid functions, so I had to write it in myself.

most-occurences.lqf uses array-remove to implement a function that finds the mode of a list. The mode is the element or elements that occur the most frequently inside the list. This function was inspired by this StackOverflow question.

Next steps

Consider exploring this Liquid functions spec, though it does seem quite old. However, the method of returning values, while limited, does guarantee type safety - as much as Liquid guarantees type safety to begin with.