How to determine a page budle, branch, or leaf?

Hi. I’ve gone through the docs a fair bit and googled but unable to figure out how to determine is page is a Bundle, Branch, or Leaf.

Does anyone know if there something like if .IsPage Bundle or Leaf of if Page.type or something. I couldn’t find anything.

The only thing I found so far was this. Trying to wrap my head around it now.

You could try {{ .File }}:

With a regular page at, you could have either (not a bundle) or (is a bundle)

So you could bundle this into a partial and have a return value:

{{ if .File }}               or or    
  {{ if .IsPage }}           or
    {{ $file := print .File }}
    {{ if in $file "" }}
      page bundle {{$file}}
    {{ else }}
      NOT a page bundle {{ $file }}
    {{ end }}
  {{ else }}                
    branch bundle: {{ .File }} 
  {{ end }}
{{ else }}
  Probably automatically-generated list .Page: {{ .IsNode }} <br>
{{ end }}

Thanks I also just found this. There is an example here similar to that. Thank you.

In case anyone else wants to know, I had to do this in a shortcode, and .File will not work there and throw errors.

Please use {{ $.Page.File }} instead for shortcode templates.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.