mirror of
https://github.com/tiennm99/hugoDocs.git
synced 2026-10-14 14:17:43 +00:00
Update Page Kinds documentation
Also fixes https://github.com/gohugoio/hugoDocs/issues/402.
This commit is contained in:
1 parent
8203f649df
commit
d332269246
1 file changed
+19
-12
@@ -26,25 +26,31 @@ To effectively leverage section page templates, you should first understand Hugo
|
|||||||
|
|
||||||
See [Template Lookup](/templates/lookup-order/).
|
See [Template Lookup](/templates/lookup-order/).
|
||||||
|
|
||||||
|
## Page Kinds
|
||||||
|
|
||||||
|
Every `Page` in Hugo has a `.Kind` attribute.
|
||||||
|
|
||||||
|
| Kind | Description | Example |
|
||||||
|
|----------------|--------------------------------------------------------------------|-------------------------------------------------------------------------------|
|
||||||
|
| `home` | The home page | `/index.html` |
|
||||||
|
| `page` | A page showing a _regular page_ | `my-post` page (`/posts/my-post/index.html`) |
|
||||||
|
| `section` | A page listing _regular pages_ from a given [_section_][sections] | `posts` section (`/posts/index.html`) |
|
||||||
|
| `taxonomy` | A page listing _regular pages_ from a given _taxonomy term_ | page for the term `awesome` from `tags` taxonomy (`/tags/awesome/index.html`) |
|
||||||
|
| `taxonomyTerm` | A page listing terms from a given _taxonomy_ | page for the `tags` taxonomy (`/tags/index.html`) |
|
||||||
|
|
||||||
## `.Site.GetPage` with Sections
|
## `.Site.GetPage` with Sections
|
||||||
|
|
||||||
Every `Page` in Hugo has a `.Kind` attribute. `Kind` can easily be combined with the [`where` function][where] in your templates to create kind-specific lists of content. This method is ideal for creating lists, but there are times where you may want to fetch just the index page of a single section via the section's path.
|
`Kind` can easily be combined with the [`where` function][where] in your templates to create kind-specific lists of content. This method is ideal for creating lists, but there are times where you may want to fetch just the index page of a single section via the section's path.
|
||||||
|
|
||||||
The [`.GetPage` function][getpage] looks up an index page of a given `Kind` and `path`.
|
The [`.GetPage` function][getpage] looks up an index page of a given `Kind` and `path`.
|
||||||
|
|
||||||
{{% note %}}
|
You can call `.Site.GetPage` with two arguments: `kind` (one of the valid values
|
||||||
`.GetPage` is not currently supported to grab single content files but *may* be supported in the future.
|
of `Kind` from above) and `kind value`.
|
||||||
{{% /note %}}
|
|
||||||
|
|
||||||
You can call `.Site.GetPage` with two arguments: `kind` and `kind value`.
|
Examples:
|
||||||
|
|
||||||
These are the valid values for 'kind':
|
|
||||||
|
|
||||||
1. `home`
|
|
||||||
2. `section`
|
|
||||||
3. `taxonomy`
|
|
||||||
4. `taxonomyTerm`
|
|
||||||
|
|
||||||
|
- `{{ .Site.GetPage "section" "posts" }}`
|
||||||
|
- `{{ .Site.GetPage "page" "search" }}`
|
||||||
|
|
||||||
## Example: Creating a Default Section Template
|
## Example: Creating a Default Section Template
|
||||||
|
|
||||||
@@ -113,3 +119,4 @@ Which then returns the following:
|
|||||||
[lists]: /templates/lists/
|
[lists]: /templates/lists/
|
||||||
[lookup]: /templates/lookup-order/
|
[lookup]: /templates/lookup-order/
|
||||||
[where]: /functions/where/
|
[where]: /functions/where/
|
||||||
|
[sections]: /content-management/sections/
|
||||||
Reference in new issue
Block a user