Jekyll filter: Use Liquid in front-matter
Jekyll’s template language Liquid is pretty powerful. We especially use Liquid objects to access different data across all pages, like
{{ site.data.placeholder.product-name }}
instead of the product name itself. However, we can’t use these objects in front-matter, where we would define titles and other meta information:
---
title: How to install {{ site.data.placeholder.product-name }}
---
Not possible. Well, not without a little help at least. Here’s a nice filter that parses Liquid objects when used within Jekyll front-matter:
module LiquidFilter
def liquify(input)
Liquid::Template.parse(input).render(@context)
end
end
Liquid::Template.register_filter(LiquidFilter)
Use it with
{{ page.title | liquify }}
Anywhere in your layouts.