Page

Layout

返回前置元数据中定义的页面布局。

签名
PAGE.Layout
返回类型
string

在前置元数据中指定 layout 字段即可指向特定模板。详见说明。

title = 'Contact'
layout = 'contact'

Hugo 会用 contact.html 渲染该页面。

layouts/
├── baseof.html
├── contact.html
├── home.html
├── page.html
├── section.html
├── taxonomy.html
└── term.html

虽然在模板中很少用到,但你可以这样取值:

{{ .Layout }}

如果前置元数据中没有定义 layout 字段,Layout 方法返回空字符串。