Children - 子(展示子页面,类似于目录功能)

children 子简码列出了当前页面的子页面及其后代.

用法

当示例使用带有命名参数的简码时,您也可以自由地从自己的部分调用此简码.

{{% children sort="weight" %}}
{{ partial "shortcodes/children.html" (dict
  "page" .
  "sort" "weight"
)}}

Parameter

名字 默认值 注释
containerstyle ul 选择用于对所有子项进行分组的样式.它可以是任何 HTML 标记名称.
style li 选择用于显示每个子体的样式,它可以是任何 HTML 标记名称.
showhidden false 设置为true时,也会显示从菜单中隐藏的子页面.
description false true在列表中的每个页面下显示一个短文本时.当页面不存在描述或摘要时,将获取内容的前 70 个单词 - 阅读有关 gohugo.io 摘要的更多信息.
depth 1 要显示的子体的深度.例如,如果值为2,则简码将显示两个级别的子页面. 若要获取所有后代,请将此值设置为较大的数字,例如:999.
sort 请参阅注释 显示列表的排序顺序.

如果未设置,则按网站和页面前言的 [ordersectionby](/hugo/themes/relearn/basics/global_config/#relearn全局配置参数) 设置进行排序

- weight: 按菜单顺序排序
- title: 在菜单标签上按字母顺序排序.

示例

全部默认

{{% children  %}}

带描述

{{% children description="true" %}}
  • Chapter_1

    章节 1 这是一个分支捆绑包

  • Chapter_2

    章节 2.1 这是一个分支捆绑包

  • Chapter_3

    章节 3 这是一个分支捆绑包

无限深度和隐藏页面

{{% children depth="999" showhidden="true" %}}

容器和元素的标题样式

{{% children containerstyle="div" style="h2" depth="3" description="true" %}}

Chapter_1

章节 1 这是一个分支捆绑包

1.1

章节 1.1 这是一个叶捆绑包

1.2

章节 1.2 这是一个叶捆绑包

Chapter_2

章节 2.1 这是一个分支捆绑包

2.1

章节2.1 这是一个叶捆绑包

Chapter_3

章节 3 这是一个分支捆绑包

3.1

章节 3.1 这是一个分支捆绑包

3.1.1

章节 3.1.1 这是一个分支捆绑包

3.1.2

章节 3.1.2 这是一个叶包

组和元素样式的 div

{{% children containerstyle="div" style="div" depth="3" %}}