Consider the following directory structure in the root directory of a hugo static site:
content
|
└── A
└──A1
├── a.md
└── b.md
└──A2
├── a.md
└── b.md
└──A3
├── a.md
└── b.md
.
.
.
All I want to do is render the ‘Content’ of the markdown files; but I want to do this directory-wise i.e., I want a separate row for all the sub-directories viz. A1, A2,… and inside each row, I want the content of the .md files inside the directory corresponding to that row. So it should look like:
/Row 1/ a.md b.md //these are files in A1
/Row 2/ a.md b.md //these are files in A2
/Row 3/ a.md b.md //these are files in A3
.
.
My efforts:
I tried iterating over folders with the loop {{ range where .Pages “Type” “A”}} and then an inner loop using ‘.’ to refer to the sub-directories; but the outer loop straight away goes to the markdowns without storing a reference to the subdirectories in the dot(.) Since everything is a page, why does this not work? More importantly how to get this done? I have tried rewriting loops and reading the hugo docs. I am new to Hugo and have no Go programming background. I know this is definitely an easy issue but it’s really annoying because I can’t seem to find the right way. Any help is appreciated. Thanks!