Is it possible to use Liquid tags in YAML Front Matter variables?
For example if test.html contains:
---
variable: "Date: {% date: '%D' %}"
---
{{ page.variable }}
then Jekyll will generate the following HTML:
Date: {% date: '%D' %}
instead of something like:
Date: 03/13/14
Basically I'd like the Liquid tags in the YAML Front Matter variables to be processed.
It sounds like you're trying to store a formatted date in a variable so you don't need to re-format the date each time you use it.
Rather than filtering the date in the front matter you could just add a Liquid capture statement just below the front matter. This will allow you assign your formatted date to a variable so you can use it in expressions.
---
title: Some sweet title
layout: default
date: 2014-9-17 # Could come from post's filename, but I put it here explicitly
---
{% capture formatted_date %}{{ page.date | date: "%-d %B %Y" }}{% endcapture %}
Once you have your new formatted date variable you can use it as an expression anywhere:
{{ formatted_date }}
outputs: 17 September 2014
More on formatting the date itself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With