Skip to content

List sub pages by menu

The following shortcode can be used to list all pages that have a specific menu and are within the content directory. Perhaps usable either for a miniature sitemap of specific directories or for index based pages.

Example

{{< list-sub-pages-by-menu menu="shortcodes" >}}

Shortcode template

Link to shortcode template on GitHub(Opens in new window)

{{ $menu := .Get "menu" }}

{{ if $menu }}
  {{ $menu = print $menu "/" }}
  <ul>
    {{ range where .Site.RegularPages "File.Dir" $menu }}
      <li>
        <a href="{{ .Permalink }}">
          {{ .Title }}
        </a>
      </li>
    {{ end }}
  </ul>
{{ end }}