mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-29 19:22:15 -05:00
5fd1e74903
``` git subtree add --prefix=docs/ https://github.com/gohugoio/hugoDocs.git master --squash ``` Closes #11925
60 lines
1.8 KiB
Markdown
60 lines
1.8 KiB
Markdown
---
|
|
title: CurrentSection
|
|
description: Returns the Page object of the section in which the given page resides.
|
|
categories: []
|
|
keywords: []
|
|
action:
|
|
related:
|
|
- methods/page/Ancestors
|
|
- methods/page/FirstSection
|
|
- methods/page/InSection
|
|
- methods/page/IsAncestor
|
|
- methods/page/IsDescendant
|
|
- methods/page/Parent
|
|
- methods/page/Sections
|
|
returnType: page.Page
|
|
signatures: [PAGE.CurrentSection]
|
|
---
|
|
|
|
{{% include "methods/page/_common/definition-of-section.md" %}}
|
|
|
|
{{% note %}}
|
|
The current section of a [section] page, [taxonomy] page, [term] page, or the home page, is itself.
|
|
|
|
[section]: /getting-started/glossary/#section
|
|
[taxonomy]: /getting-started/glossary/#taxonomy
|
|
[term]: /getting-started/glossary/#term
|
|
{{% /note %}}
|
|
|
|
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>
|
|
```
|