Debian Codegraph @

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

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