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

---
[section（内容区块）](/quick-reference/glossary/section/)

内容结构如下：

```tree
content/
├── lessons/
│   ├── math/
│   │   ├── _index.md
│   │   ├── lesson-1.md
│   │   └── lesson-2.md
│   └── _index.md
└── _index.md
```

渲染 lesson-1.md 时：

```go-html-template
{{ .Section }} → lessons
```

上例中 “lessons” 就是顶层 section。

`Section` 方法常与 [`where`][] 函数搭配使用，用来构建页面集合。

```go-html-template
{{ range where .Site.RegularPages "Section" "lessons" }}
  <h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
```

这与把 [`Type`][] 方法与 `where` 函数搭配使用类似

```go-html-template
{{ range where .Site.RegularPages "Type" "lessons" }}
  <h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
```

不过，如果有一个或多个页面在前置元数据中定义了 `type` 字段，那么基于 `Type` 的页面集合会与基于 `Section` 的页面集合不同。

[`Type`]: /methods/page/type/
[`where`]: /functions/collections/where/

