Code sometimes does not output anything

no worries all fine for me

it does not have to be an inline partial, a regular one will do.

_shortcodes/listpages.html

{{ $section := .Get "section" }}
{{ $maxdepth := .Get "maxdepth" | default 0 | int }}
{{ $start := site.GetPage "section" $section }}

{{ if $start }}
  {{ partial "listpages-recurse" (dict
    "page" $start
    "level" 1
    "max" $maxdepth
  ) }}
{{ else }}
  <p>Section "{{ $section }}" not found.</p>
{{ end }}
_partials/listpages-recurse.html
{{ $page := .page }}
{{ $level := .level }}
{{ $max := .max }}

{{ if or (eq $max 0) (le $level $max) }}
  {{ if $page.Pages }}
    <ul>
      {{ range $page.Pages }}
        <li>
          <a href="{{ .Permalink }}">{{ .Title }}</a>
          {{ partial "listpages-recurse" (dict
            "page" .
            "level" (add $level 1)
            "max" $max
          ) }}
        </li>
      {{ end }}
    </ul>
  {{ end }}
{{ end }}

but as I said no differences for me … btw I’m on version 0.156.0

1 Like