Debian Codegraph @

docs/content/en/_common/permalink-tokens.md

raw
1 ---
2 _comment: Do not remove front matter.
3 ---
4
5 `:year`
6 : The 4-digit year as defined in the front matter `date` field.
7
8 `:month`
9 : The 2-digit month as defined in the front matter `date` field.
10
11 `:monthname`
12 : The name of the month as defined in the front matter `date` field.
13
14 `:day`
15 : The 2-digit day as defined in the front matter `date` field.
16
17 `:weekday`
18 : The 1-digit day of the week as defined in the front matter `date` field (Sunday = `0`).
19
20 `:weekdayname`
21 : The name of the day of the week as defined in the front matter `date` field.
22
23 `:yearday`
24 : The 1- to 3-digit day of the year as defined in the front matter `date` field.
25
26 `:section`
27 : The content's section.
28
29 `:sectionslug`
30 : {{< new-in 0.149.0 />}}
31 : 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.
32
33 `:sections`
34 : 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.
35
36 `:sectionslugs`
37 : {{< new-in 0.149.0 />}}
38 : 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.
39
40 `:title`
41 : 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.
42
43 `:slug`
44 : The `slug` as defined in front matter, else 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.
45
46 `:filename`
47 : {{< deprecated-in v0.144.0 />}}
48 : Use the [`:contentbasename`](#contentbasename) token instead.
49
50 `:slugorfilename`
51 : {{< deprecated-in v0.144.0 />}}
52 : Use the [`:slugorcontentbasename`](#slugorcontentbasename) token instead.
53
54 `:contentbasename`
55 : {{< new-in 0.144.0 />}}
56 : The [content base name][].
57
58 `:slugorcontentbasename`
59 : {{< new-in 0.144.0 />}}
60 : The `slug` as defined in front matter, else the [content base name][].
61
62 For time-related values, you can also use the layout string components defined in Go's [time package][]. For example:
63
64 {{< code-toggle file=hugo >}}
65 permalinks:
66 posts: /:06/:1/:2/:title/
67 {{< /code-toggle >}}
68
69 [content base name]: /methods/page/file/#contentbasename
70 [time package]: https://pkg.go.dev/time#pkg-constants