Debian Codegraph @

docs/content/en/methods/page/FirstSection.md

raw
1 ---
2 title: FirstSection
3 description: Returns the Page object of the top-level section of which the given page is a descendant.
4 categories: []
5 keywords: []
6 params:
7 functions_and_methods:
8 returnType: page.Page
9 signatures: [PAGE.FirstSection]
10 ---
11
12 {{% glossary-term section %}}
13
14 > [!NOTE]
15 > When called on the home page, the `FirstSection` method returns the `Page` object of the home page itself.
16
17 Consider this content structure:
18
19 ```tree
20 content/
21 ├── auctions/
22 │ ├── 2023-11/
23 │ │ ├── _index.md <-- first section: auctions
24 │ │ ├── auction-1.md
25 │ │ └── auction-2.md <-- first section: auctions
26 │ ├── 2023-12/
27 │ │ ├── _index.md
28 │ │ ├── auction-3.md
29 │ │ └── auction-4.md
30 │ ├── _index.md <-- first section: auctions
31 │ ├── bidding.md
32 │ └── payment.md <-- first section: auctions
33 ├── books/
34 │ ├── _index.md <-- first section: books
35 │ ├── book-1.md
36 │ └── book-2.md <-- first section: books
37 ├── films/
38 │ ├── _index.md <-- first section: films
39 │ ├── film-1.md
40 │ └── film-2.md <-- first section: films
41 └── _index.md <-- first section: home
42 ```
43
44 To link to the top-level section of which the current page is a descendant:
45
46 ```go-html-template
47 <a href="{{ .FirstSection.RelPermalink }}">{{ .FirstSection.LinkTitle }}</a>
48 ```