summaryrefslogtreecommitdiffstats
path: root/docs/content/en/methods/site/Sections.md
blob: 0ddaf0626539ab3c8dd2a40de1b5d763a4a5bdd6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
---
title: Sections
description: Returns a collection of top-level section pages.
categories: []
keywords: []
params:
  functions_and_methods:
    returnType: page.Pages
    signatures: [SITE.Sections]
---

The `Sections` method on a `Site` object returns a collection of top-level [section pages](g), in the [default sort order](g).

Given this content structure:

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

This template:

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

Is rendered to:

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