mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-29 22:29:56 +02:00
Merge commit '5be51ac3db225d5df501ed1fa1499c41d97dbf65'
This commit is contained in:
@@ -3,15 +3,13 @@ title: Pages
|
||||
description: Returns a collection of regular pages within the current section, and section pages of immediate descendant sections.
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- methods/page/RegularPages
|
||||
- methods/page/RegularPagesRecursive
|
||||
returnType: page.Pages
|
||||
signatures: [PAGE.Pages]
|
||||
params:
|
||||
functions_and_methods:
|
||||
returnType: page.Pages
|
||||
signatures: [PAGE.Pages]
|
||||
---
|
||||
|
||||
The `Pages` 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).
|
||||
The `Pages` 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).
|
||||
|
||||
Range through the page collection in your template:
|
||||
|
||||
@@ -72,14 +70,13 @@ When rendering lesson-2, the `Pages` method returns:
|
||||
|
||||
In the last example, the collection includes pages in the resources subdirectory. That directory is not a [section](g)---it does not contain an `_index.md` file. Its contents are part of the lesson-2 section.
|
||||
|
||||
{{% note %}}
|
||||
When used with a `Site` object, the `Pages` method recursively returns all pages within the site. See [details].
|
||||
|
||||
[details]: /methods/site/pages/
|
||||
{{% /note %}}
|
||||
> [!note]
|
||||
> When used with a `Site` object, the `Pages` method recursively returns all pages within the site. See [details].
|
||||
|
||||
```go-html-template
|
||||
{{ range .Site.Pages.ByTitle }}
|
||||
<h2><a href="{{ .RelPermalink }}">{{ .Title }}</a></h2>
|
||||
{{ end }}
|
||||
```
|
||||
|
||||
[details]: /methods/site/pages/
|
||||
|
Reference in New Issue
Block a user