2021-08-25 11:33:29 +00:00
+++
alwaysopen = false
description = "List the child pages of a page"
title = "Children"
+++
2017-08-20 15:10:29 +00:00
2023-01-14 00:39:28 +00:00
The `children` shortcode lists the child pages of the current page and its descendants.
2017-08-20 15:10:29 +00:00
2022-06-22 22:03:24 +00:00
{{% children sort="weight" %}}
2023-05-31 21:44:27 +00:00
2017-08-20 15:10:29 +00:00
## Usage
2022-06-22 22:03:24 +00:00
While the examples are using shortcodes with named parameter you are free to also call this shortcode from your own partials.
2023-07-27 15:02:13 +00:00
{{< tabs groupid = "shortcode-parameter" > }}
2023-06-05 21:20:37 +00:00
{{% tab title="shortcode" %}}
2022-06-22 22:03:24 +00:00
2022-06-05 17:31:59 +00:00
````go
2022-06-22 22:03:24 +00:00
{{%/* children sort="weight" */%}}
2022-06-05 17:31:59 +00:00
````
2022-06-22 22:03:24 +00:00
{{% /tab %}}
2023-06-05 21:20:37 +00:00
{{% tab title="partial" %}}
2022-06-22 22:03:24 +00:00
````go
{{ partial "shortcodes/children.html" (dict
2023-07-27 14:14:55 +00:00
"page" .
2022-06-22 22:03:24 +00:00
"sort" "weight"
)}}
````
{{% /tab %}}
{{< / tabs > }}
2022-06-05 17:31:59 +00:00
### Parameter
| Name | Default | Notes |
2023-07-27 14:07:01 +00:00
|--------------------|-------------------|-------------|
2022-06-05 17:31:59 +00:00
| **containerstyle** | `ul` | Choose the style used to group all children. It could be any HTML tag name. |
| **style** | `li` | Choose the style used to display each descendant. It could be any HTML tag name. |
2022-10-31 11:10:36 +00:00
| **showhidden** | `false` | When `true` , child pages hidden from the menu will be displayed as well. |
2022-06-05 17:31:59 +00:00
| **description** | `false` | When `true` shows a short text under each page in the list. When no description or summary exists for the page, the first 70 words of the content is taken - [read more info about summaries on gohugo.io ](https://gohugo.io/content/summaries/ ). |
| **depth** | `1` | The depth of descendants to display. For example, if the value is `2` , the shortcode will display two levels of child pages. To get all descendants, set this value to a high number eg. `999` . |
2023-11-20 23:53:33 +00:00
| **sort** | `auto` | The sort criteria of the displayed list.< br >< br > - `auto` defaults to [`ordersectionsby` of the pages frontmatter ](cont/pages#frontmatter-configuration )< br > or to [`ordersectionsby` of the site configuration ](basics/configuration )< br > or to `weight` < br > - `weight` < br > - `title` < br > - `linktitle` < br > - `modifieddate` < br > - `expirydate` < br > - `publishdate` < br > - `date` < br > - `length` < br > - `default` adhering to Hugo's default sort criteria|
2022-06-05 17:31:59 +00:00
## Examples
2017-08-20 15:10:29 +00:00
2022-06-05 17:31:59 +00:00
### All Default
2017-08-20 15:10:29 +00:00
2021-08-23 22:25:15 +00:00
````go
{{%/* children */%}}
````
2017-08-20 15:10:29 +00:00
{{% children %}}
2022-06-05 17:31:59 +00:00
### With Description
2021-08-23 22:25:15 +00:00
````go
{{%/* children description="true" */%}}
````
2017-08-20 15:10:29 +00:00
2019-11-02 07:20:59 +00:00
{{%children description="true" %}}
2017-08-20 15:10:29 +00:00
2022-10-31 11:10:36 +00:00
### Infinite Depth and Hidden Pages
2022-06-05 17:31:59 +00:00
2021-08-23 22:25:15 +00:00
````go
2021-08-26 18:54:31 +00:00
{{%/* children depth="999" showhidden="true" */%}}
2021-08-23 22:25:15 +00:00
````
2017-08-20 15:10:29 +00:00
2021-08-26 18:54:31 +00:00
{{% children depth="999" showhidden="true" %}}
2017-08-20 15:10:29 +00:00
2022-06-05 17:31:59 +00:00
### Heading Styles for Container and Elements
2021-08-23 22:25:15 +00:00
````go
2021-08-25 12:45:01 +00:00
{{%/* children containerstyle="div" style="h2" depth="3" description="true" */%}}
2021-08-23 22:25:15 +00:00
````
2017-08-20 15:10:29 +00:00
2021-08-25 12:45:01 +00:00
{{% children containerstyle="div" style="h2" depth="3" description="true" %}}
2017-08-20 15:10:29 +00:00
2022-06-05 17:31:59 +00:00
### Divs for Group and Element Styles
2021-08-23 22:25:15 +00:00
````go
2022-06-05 17:31:59 +00:00
{{%/* children containerstyle="div" style="div" depth="3" */%}}
2021-08-23 22:25:15 +00:00
````
2017-08-20 15:10:29 +00:00
2022-06-05 17:31:59 +00:00
{{% children containerstyle="div" style="div" depth="3" %}}