节区
Syntax
PAGE.Sections
Returns
page.Pages
一个 章节 是一个顶级内容目录,或者任何包含 index.md 文件的内容目录。
采用以下内容结构:
content/
├── auctions/
│ ├── 2023-11/
│ │ ├── _index.md <-- front matter: weight = 202311
│ │ ├── auction-1.md
│ │ └── auction-2.md
│ ├── 2023-12/
│ │ ├── _index.md <-- front matter: weight = 202312
│ │ ├── auction-3.md
│ │ └── auction-4.md
│ ├── _index.md <-- front matter: weight = 30
│ ├── bidding.md
│ └── payment.md
├── books/
│ ├── _index.md <-- front matter: weight = 20
│ ├── book-1.md
│ └── book-2.md
├── films/
│ ├── _index.md <-- front matter: weight = 10
│ ├── film-1.md
│ └── film-2.md
└── _index.md
以及以下模板:
{{ range .Sections.ByWeight }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}
在主页上,Hugo 呈现:
<h2><a href="/films/">Films</a></h2>
<h2><a href="/books/">Books</a></h2>
<h2><a href="/auctions/">Auctions</a></h2>
在拍卖页面上,Hugo 呈现:
<h2><a href="/auctions/2023-11/">Auctions in November 2023</a></h2>
<h2><a href="/auctions/2023-12/">Auctions in December 2023</a></h2>