Layout

在前端配置中指定 layout 字段以針對特定模板。詳見 詳細資訊

content/contact.md.
     
layout: contact
title: Contact
layout = 'contact'
title = 'Contact'
{
   "layout": "contact",
   "title": "Contact"
}

Hugo 將使用 contact.html 渲染該頁面。

layouts/
└── _default/
    ├── baseof.html
    ├── contact.html
    ├── home.html
    ├── list.html
    └── single.html

雖然在模板中很少使用,您可以使用以下方法訪問該值:

{{ .Layout }}

如果前端配置中未定義 layout 字段,則 Layout 方法將返回空字串。