1

I have a template that looks like this:

---
date: "2016-01-01T06:00-06:00"
value: "/{{ page.date | date: '%Y/%m/%d' }}/index.html"
---

Value prints: {{ value }} <br/>
But we expect: {{ page.date | date: '%Y/%m/%d' }}/index.html <br/>

When I render the site then the site looks like this:

Value prints: /{{ page.date | date: '%Y/%m/%d' }}/index.html
But we expect: 2016/01/01/index.html

I really want the value parameter to have the expected value.

As far as I can tell, this sort of thing should work. I want to use this technique to calculate permalinks. My thinking is based on https://www.11ty.dev/docs/permalinks/

I'm running eleventy 0.12.1

Things I've tried:

  • yaml, json and js frontmatter
  • markdown template
  • njk template
  • literally copy pasting sample code from the docs

At this point I think Eleventy might have a bug

Sheena
  • 15,590
  • 14
  • 75
  • 113

1 Answers1

4

At the moment of writing, eleventy doesn't support template syntax in any frontmatter fields except the permalink field:

permalink: Change the output target of the current template. Normally, you cannot use template syntax to reference other variables in your data, but permalink is an exception.

Source

Instead, you can use computed data, which allows you to set frontmatter data based on other frontmatter fields. Something like this should work:

date: "2016-01-01T06:00-06:00"
eleventyComputed:
    value: "/{{ page.date | date: '%Y/%m/%d' }}/index.html"
MoritzLost
  • 2,611
  • 2
  • 18
  • 32