summaryrefslogtreecommitdiffstats
path: root/docs/content/en/methods/page/FirstSection.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/content/en/methods/page/FirstSection.md')
-rw-r--r--docs/content/en/methods/page/FirstSection.md56
1 files changed, 56 insertions, 0 deletions
diff --git a/docs/content/en/methods/page/FirstSection.md b/docs/content/en/methods/page/FirstSection.md
new file mode 100644
index 000000000..f757aa2d2
--- /dev/null
+++ b/docs/content/en/methods/page/FirstSection.md
@@ -0,0 +1,56 @@
+---
+title: FirstSection
+description: Returns the Page object of the top level section of which the given page is a descendant.
+categories: []
+keywords: []
+action:
+ related:
+ - methods/page/Ancestors
+ - methods/page/CurrentSection
+ - methods/page/InSection
+ - methods/page/IsAncestor
+ - methods/page/IsDescendant
+ - methods/page/Parent
+ - methods/page/Sections
+ returnType: hugolib.pageState
+ signatures: [PAGE.FirstSection]
+---
+
+{{% include "methods/page/_common/definition-of-section.md" %}}
+
+{{% note %}}
+When called on the home page, the `FirstSection` method returns the `Page` object of the home page itself.
+{{% /note %}}
+
+Consider this content structure:
+
+```text
+content/
+├── auctions/
+│ ├── 2023-11/
+│ │ ├── _index.md <-- first section: auctions
+│ │ ├── auction-1.md
+│ │ └── auction-2.md <-- first section: auctions
+│ ├── 2023-12/
+│ │ ├── _index.md
+│ │ ├── auction-3.md
+│ │ └── auction-4.md
+│ ├── _index.md <-- first section: auctions
+│ ├── bidding.md
+│ └── payment.md <-- first section: auctions
+├── books/
+│ ├── _index.md <-- first section: books
+│ ├── book-1.md
+│ └── book-2.md <-- first section: books
+├── films/
+│ ├── _index.md <-- first section: films
+│ ├── film-1.md
+│ └── film-2.md <-- first section: films
+└── _index.md <-- first section: home
+```
+
+To link to the top level section of which the current page is a descendant:
+
+```go-html-template
+<a href="{{ .FirstSection.RelPermalink }}">{{ .FirstSection.LinkTitle }}</a>
+```