# Layout
> 返回前置元数据中定义的页面布局。
- 官方英文原文：https://gohugo.io/methods/page/layout/
- 本页规范地址：https://hugozh.cn/methods/page/layout/
- 最近更新：2026-10-02
- 最后提交：912b1d3 chore(site): 添加 static/CNAME（hugozh.cn），供 GitHub Pages 等平台绑定自定义域名
- 签名：PAGE.Layout
- 返回类型：string
- 站点：Hugo 中文文档（https://hugozh.cn/）· 社区维护的非官方中文翻译，如有出入以官方英文原文为准

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

```toml
title = 'Contact'
layout = 'contact'
```

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

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

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

```go-html-template
{{ .Layout }}
```

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

[说明]: /templates/lookup-order/#target-a-template

