Listing nested directories


I have the following structure for the content where the section « Projects » is structured with nested subfolders with 2 levels:

└── Projects
    ├── project-A
    	|-- post-A1
	|-- post-A2
    	|-- post-A3
	|-- post-A4
    └── Project-B
    	|-- post-B1
	|-- post-B2
    	|-- post-B3
	|-- post-B4

How to list only the first level of subfolders, meaning listing only the information from at the first level with the result as follows :

-	Project A
-	Project B
-	Etc.

With no listing of the post-A1, post-A2, etc…
Thanks for your help

(.Site.GetPage "section" "Projects").Sections should give you the sections you want.

Thank you but it doesn’t work.

@Polarhardboiled Just to make sure, are you doing this (below), and it doesn’t work?

{{ $sections := (.Site.GetPage "section" "Projects").Sections }}


{{ range $sections }}
{{ .Title }} <!-- or whatever -->
{{ end }}

And one more note. I believe the section name is case sensitive, so if your folder name is “projects” make sure you’re using lower case. You can avoid this altogether by using something like this:

{{ $sections := (.Site.GetPage "section" .Section).Sections }}

Note, instead of using Projects I used .Section which will pick up whatever section you’re currently on.

1 Like

Thank you