I'm migrating a Jekyll site to Eleventy using Liquid templates.
In Jekyll, it's possible to access the current page's front matter data in a layout simply by using the page variable. For instance, I can print the page title using {{ page.title }}. I understand that in Eleventy front matter is stored under data, but {{ page.data.title }} gives me nothing, and indeed the entire data key seems to be missing.
What's the intended way to access front matter data of the current page (in a layout)?
I'm not sure how much the template engine impacts this, but in liquid I just use {{ title }} to get the title: item from the front matter. I only use the .data. method when working with data from collections.
Ah, you're right. Thank you!
It is in my opinion somewhat unintuitive that page doesn't have the same structure as when reading it from a collection. Adding to the confusion is that both "collection" and "current" forms of the page contain some of the properties I would expect, like date and url, with the former also defined in the front matter.
I'm closing this as my question was answered.
It is in my opinion somewhat unintuitive that page doesn't have the same structure as when reading it from a collection.
@proog You may be interested in #338.
Most helpful comment
I'm not sure how much the template engine impacts this, but in liquid I just use
{{ title }}to get thetitle:item from the front matter. I only use the.data.method when working with data from collections.