mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-30 22:39:58 +02:00
Merge commit '35dec7c96f7ee3eb17dd444f7067f0c776fb56ae'
This commit is contained in:
40
docs/content/en/methods/page/Layout.md
Normal file
40
docs/content/en/methods/page/Layout.md
Normal file
@@ -0,0 +1,40 @@
|
||||
---
|
||||
title: Layout
|
||||
description: Returns the layout for the given page as defined in front matter.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/Type
|
||||
returnType: string
|
||||
signatures: [PAGE.Layout]
|
||||
---
|
||||
|
||||
Specify the `layout` field in front matter to target a particular template. See [details].
|
||||
|
||||
[details]: /templates/lookup-order/#target-a-template
|
||||
|
||||
{{< code-toggle file=content/contact.md >}}
|
||||
title = 'Contact'
|
||||
layout = 'contact'
|
||||
{{< /code-toggle >}}
|
||||
|
||||
Hugo will render the page using contact.html.
|
||||
|
||||
```text
|
||||
layouts/
|
||||
└── _default/
|
||||
├── baseof.html
|
||||
├── contact.html
|
||||
├── home.html
|
||||
├── list.html
|
||||
└── single.html
|
||||
```
|
||||
|
||||
Although rarely used within a template, you can access the value with:
|
||||
|
||||
```go-html-template
|
||||
{{ .Layout }}
|
||||
```
|
||||
|
||||
The `Layout` method returns an empty string if the `layout` field in front matter is not defined.
|
Reference in New Issue
Block a user