HUGO
Menu
GitHub 90426 stars Mastodon

Layout

Returns the layout of the given page as defined in front matter.
Syntax
PAGE.Layout
Returns
string

Usage

The Layout method on a Page object returns the layout of the given page as defined by the layout field in front matter. If the layout field is not defined, the method returns an empty string.

Set the layout field in front matter to target a specific template. This method is rarely used within a template.

Examples

Given this front matter:

---
layout: contact
title: Contact
---
+++
layout = 'contact'
title = 'Contact'
+++
{
   "layout": "contact",
   "title": "Contact"
}
{{ .Layout }} → contact