resources/page: Add :sectionslug and :sectionslugs permalink tokens

Add slugified section permalink tokens with fallback behavior and slice syntax support.

Fixes #13788
This commit is contained in:
Dustin Fischer
2025-08-23 12:35:21 +02:00
committed by GitHub
parent c14fdddada
commit 12ace3ad5c
5 changed files with 198 additions and 5 deletions

View File

@@ -26,9 +26,15 @@ _comment: Do not remove front matter.
`:section`
: The content's section.
`:sectionslug`
: The content's section using slugified section name. The slugified section name is the `slug` as defined in front matter, else the `title` as defined in front matter, else the automatic title.
`:sections`
: The content's sections hierarchy. You can use a selection of the sections using _slice syntax_: `:sections[1:]` includes all but the first, `:sections[:last]` includes all but the last, `:sections[last]` includes only the last, `:sections[1:2]` includes section 2 and 3. Note that this slice access will not throw any out-of-bounds errors, so you don't have to be exact.
`:sectionslugs`
: The content's sections hierarchy using slugified section names. The slugified section name is the `slug` as defined in front matter, else the `title` as defined in front matter, else the automatic title. You can use a selection of the sections using _slice syntax_: `:sectionslugs[1:]` includes all but the first, `:sectionslugs[:last]` includes all but the last, `:sectionslugs[last]` includes only the last, `:sectionslugs[1:2]` includes section 2 and 3. Note that this slice access will not throw any out-of-bounds errors, so you don't have to be exact.
`:title`
: The `title` as defined in front matter, else the automatic title. Hugo generates titles automatically for section, taxonomy, and term pages that are not backed by a file.