| 1 |
--- |
| 2 |
title: Sections |
| 3 |
description: Returns a collection of top-level section pages. |
| 4 |
categories: [] |
| 5 |
keywords: [] |
| 6 |
params: |
| 7 |
functions_and_methods: |
| 8 |
returnType: page.Pages |
| 9 |
signatures: [SITE.Sections] |
| 10 |
--- |
| 11 |
|
| 12 |
The `Sections` method on a `Site` object returns a collection of top-level [section pages](g), in the [default sort order](g). |
| 13 |
|
| 14 |
Given this content structure: |
| 15 |
|
| 16 |
```text |
| 17 |
content/ |
| 18 |
├── books/ |
| 19 |
│ ├── book-1.md |
| 20 |
│ └── book-2.md |
| 21 |
├── films/ |
| 22 |
│ ├── film-1.md |
| 23 |
│ └── film-2.md |
| 24 |
└── _index.md |
| 25 |
``` |
| 26 |
|
| 27 |
This template: |
| 28 |
|
| 29 |
```go-html-template |
| 30 |
{{ range .Site.Sections }} |
| 31 |
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2> |
| 32 |
{{ end }} |
| 33 |
``` |
| 34 |
|
| 35 |
Is rendered to: |
| 36 |
|
| 37 |
```html |
| 38 |
<h2><a href="/books/">Books</a></h2> |
| 39 |
<h2><a href="/films/">Films</a></h2> |
| 40 |
``` |