Collections - indented based on folder hierachy

I’d like to show a brief collection on one page. the collection being a concise list of title and url for each of it’s children. each level is indented like:

  • folder 1
    – folder 1, page 1
    – folder 1, page 2
    – folder1 subfolder 1
    — folder1 subfolder 1, page 1
  • folder 2
    – folder 2 page 1
  • folder 3

I tried loop.index (in my twig) as a means to determine depth, but that doesnt work as it increases all the time. I need a ‘depth’ variable, but cant find any not of this anywhere, so I think I am looking for the wrong word/s

@AlKissack, Collections are an array, not a tree…

In Twig, you can recursively loop through the page.children collection.

Have a look at how Quark constructs a nested menu with children and grandchildren: grav-theme-quark/templates/macros/macros.html.twig at develop · getgrav/grav-theme-quark · GitHub

1 Like