Layout variable in the frontmatter. How to read it?

I never needed of this before, and I thought the Layout variable to be accessible in the current_page.data collection, but this is not the case.

Am I missing something obvious here?

Thanks

Can you explain a bit more about what you are trying to do?

Hey Tom,

In building the pages, the frontmatter has a property Layout that allow you to control which “template” you can use to rendere the page.

The property is passed directly to Middleman and in recalling something like current_page.data the Layout property is not there. Useless to say that a current_page.data.layout returns empty even if is valorised within a frontmatter like this

---
layout: 404page
cssLayout: about
title: SendPageTitle
sitemap: false
robots: noindex
---

Yeah, I’m familiar with frontmatter, just trying to figure out why it’s not working. I’m seeing the same thing, apparently you can’t read from that property.

Very annoying. Any idea?

Just found this github issue that solves the problem.

current_page.options[:layout]

2 Likes