Debian Codegraph @

docs/content/en/methods/page/RegularPages.md

raw
1 ---
2 title: RegularPages
3 description: Returns a collection of regular pages within the current section.
4 categories: []
5 keywords: []
6 params:
7 functions_and_methods:
8 returnType: page.Pages
9 signatures: [PAGE.RegularPages]
10 ---
11
12 The `RegularPages` method on a `Page` object is available to these [page kinds](g): `home`, `section`, `taxonomy`, and `term`. The templates for these page kinds receive a page [collection](g) in [context](g), in the [default sort order](g).
13
14 Range through the page collection in your template:
15
16 ```go-html-template
17 {{ range .RegularPages.ByTitle }}
18 <h2><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
19 {{ end }}
20 ```
21
22 Consider this content structure:
23
24 ```tree
25 content/
26 ├── lessons/
27 │ ├── lesson-1/
28 │ │ ├── _index.md
29 │ │ ├── part-1.md
30 │ │ └── part-2.md
31 │ ├── lesson-2/
32 │ │ ├── resources/
33 │ │ │ ├── task-list.md
34 │ │ │ └── worksheet.md
35 │ │ ├── _index.md
36 │ │ ├── part-1.md
37 │ │ └── part-2.md
38 │ ├── _index.md
39 │ ├── grading-policy.md
40 │ └── lesson-plan.md
41 ├── _index.md
42 ├── contact.md
43 └── legal.md
44 ```
45
46 When rendering the home page, the `RegularPages` method returns:
47
48 contact.md
49 legal.md
50
51 When rendering the lessons page, the `RegularPages` method returns:
52
53 lessons/grading-policy.md
54 lessons/lesson-plan.md
55
56 When rendering lesson-1, the `RegularPages` method returns:
57
58 lessons/lesson-1/part-1.md
59 lessons/lesson-1/part-2.md
60
61 When rendering lesson-2, the `RegularPages` method returns:
62
63 lessons/lesson-2/part-1.md
64 lessons/lesson-2/part-2.md
65 lessons/lesson-2/resources/task-list.md
66 lessons/lesson-2/resources/worksheet.md
67
68 In the last example, the collection includes pages in the resources subdirectory. That directory is not a [section](g)---it does not contain an&nbsp;`_index.md`&nbsp;file. Its contents are part of the lesson-2 section.
69
70 > [!NOTE]
71 > When used with the `Site` object, the `RegularPages` method recursively returns all regular pages within the site. See [details][].
72
73 ```go-html-template
74 {{ range .Site.RegularPages.ByTitle }}
75 <h2><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
76 {{ end }}
77 ```
78
79 [details]: /methods/site/regularpages/