Need some assistance to display branches folders as Page

Hi there,

I have this content structure :

  • content/fr/folder_material/_index.html
  • content/fr/folder_material/folder_FDM/_index.html
  • content/fr/folder_material/folder_FDM/pla.html
  • content/fr/folder_material/folder_RESINE/_index.html
  • content/fr/folder_material/folder_RESINE/gray.html
│   config.toml
├───content
│   └───fr
│       │  
│       │   
│       └───folder_material
│           |         _index.md
│           |    
│           |_____folder_FDM
│           |          _index.md
│           |          pla.html
│           |    
│           |_____folder_RESINE
│           |           _index.md
│           |           gray.html

I loop through my pages in my custom layout list.html of the material section using the code below :


 {{ range .RegularPages.GroupBy "Section"  }}
        {{ range .Pages }}

        {{ end }}
{{ end }}

It lists the sub content for folder_FDM and folder_RESINE , and that’s great,

but the page /folder_material is empty.

I understand that the folder_material is a branch without any content beside its sub-folders

Now, I really would like to list the 2 sub-sections one for each sub-folders in the folder_material page :

I am trying to make the folder_material/ page
to show the sub sections :
folder_FDM > with link to /folder_FDM
and
folder_RESINE > with link to /folder_RESINE

I tried to make the folder_material a leaf to hard code the data towards the sub-folders (folder_FDM and folder_RESINE), but then the leaf behavior brakes the display that already works for the sub-content in folder_FDM/ and folder_RESINE/

Thanks for any advice.

Ok I have found the solution :slight_smile:

Two loops one above the other,
for two different things :

  1. loop for Sections

       {{ range .Sections  }}
  1. loop for pages (regular ones)

        {{ range .RegularPages.GroupBy "Section"  }}
        {{ range .Pages }}

And it works well.

For any one going throught the same path, here is how I managed to get the menu display individual sections

                        {{ if eq .Identifier "materials" }}
[....]
                                       {{ range (where $.Site.Pages "Section" "materials") }}
                                          {{ range .Sections }}
                                             <li><a href="{{ .RelPermalink }}">{{ .Title }}</a> </li>
                                          {{ end }}
                                       {{ end }}
[....]
                        {{ end }}

You can also make use of RegularPagesRecursive.

1 Like

thanks Frjo I’ll try that !

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