blob: 93457f13f20bb3c91bd5a1cc87511c07bb4c6ff6 (
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
41
42
43
44
45
46
47
48
|
---
title: CurrentSection
description: Returns the Page object of the section in which the given page resides.
categories: []
keywords: []
params:
functions_and_methods:
returnType: page.Page
signatures: [PAGE.CurrentSection]
---
{{% glossary-term section %}}
> [!note]
> The current section of a [section page](g), [taxonomy page](g), [term page](g), or the home page, is itself.
Consider this content structure:
```text
content/
├── auctions/
│ ├── 2023-11/
│ │ ├── _index.md <-- current section: 2023-11
│ │ ├── auction-1.md
│ │ └── auction-2.md <-- current section: 2023-11
│ ├── 2023-12/
│ │ ├── _index.md
│ │ ├── auction-3.md
│ │ └── auction-4.md
│ ├── _index.md <-- current section: auctions
│ ├── bidding.md
│ └── payment.md <-- current section: auctions
├── books/
│ ├── _index.md <-- current section: books
│ ├── book-1.md
│ └── book-2.md <-- current section: books
├── films/
│ ├── _index.md <-- current section: films
│ ├── film-1.md
│ └── film-2.md <-- current section: films
└── _index.md <-- current section: home
```
To create a link to the current section page:
```go-html-template
<a href="{{ .CurrentSection.RelPermalink }}">{{ .CurrentSection.LinkTitle }}</a>
```
|