Layout
返回 front matter 中定义的给定页面的布局。
Syntax
PAGE.Layout
Returns
string
在 front matter 中指定 layout 字段以定位特定模板。详见 详情。
---
layout: contact
title: Contact
---+++
layout = 'contact'
title = 'Contact'
+++{
"layout": "contact",
"title": "Contact"
}
Hugo 将使用 contact.html 渲染页面。
layouts/
├── baseof.html
├── contact.html
├── home.html
├── page.html
├── section.html
├── taxonomy.html
└── term.html虽然很少在模板中使用,但您可以使用以下方式访问该值:
{{ .Layout }}如果 front matter 中未定义 layout 字段,Layout 方法返回空字符串。