Site

Sections

返回顶层 section 页面的集合。

签名
SITE.Sections
返回类型
page.Pages

Site 对象上的 Sections 方法按默认排序返回顶层 section 页面的集合。

给定如下内容结构:

content/
├── books/
│   ├── book-1.md
│   └── book-2.md
├── films/
│   ├── film-1.md
│   └── film-2.md
└── _index.md

这个模板:

{{ range .Site.Sections }}
  <h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }}

渲染结果为:

<h2><a href="/books/">Books</a></h2>
<h2><a href="/films/">Films</a></h2>