HUGO

How can I list every file in multiple subfolders

Hello. I have a Hugo site running through Hugo v0.83.1-extended that contains a content folder organized with this hierarchy:

content
|    |
|    folder
|    |   |
|    |   _index.md
|    |   |
|    |   subfolder
|    |   |   _index.md
|    |   |   first.md
|    |   |   second.md
|    |   |   third.md
|    |   |   fourth.md
|    |   |
|    |   other_subfolder
|    |   |   _index.md
|    |   |   first.md
|    |   |   second.md
|    |   |   third.md

I am trying to list every file in every subfolder.
Basically, my goal is to show on the homepage a list of every file in each subfolder, like this:

subfolder/_index.md
subfolder/first.md
subfolder/second.md
subfolder/third.md
subfolder/fourth.md
other_subfolder/_index.md
other_subfolder/first.md
other_subfolder/second.md
other_subfolder/third.md

So I wrote this in my template index.html :

{{ $folder := .Site.GetPage "folder" }}
<ol>
{{ range $folder.Pages }}
    <li>{{ .RelPermalink }}</li>
{{ end }}
</ol>

But I’m getting this as the result:

1. /folder/other_subfolder/
2. /folder/subfolder/
3. /folder/other_subfolder/second/
4. /folder/other_subfolder/third/

So I am missing a couple of files here and there, like /folder/subfolder/first/ or folder/other_subfolder/first/.
Could you help and explain me what I am doing wrong, please?

Thank you very much in advance.

P.S. : For completeness, I have uploaded the whole Hugo website here: test-hugo.zip - Google Drive

Please read this:
https://gohugo.io/variables/site/#site-pages

Thank you very much.

So I suppose that the fastest thing I could do is to ignore _index.md files and substitute this row:

{{ range $folder.Pages }}

with this:

{{ range $folder.RegularPagesRecursive }}

And it works… partially:

1. /folder/other_subfolder/first/
2. /folder/subfolder/first/
3. /folder/subfolder/fourth/
4. /folder/other_subfolder/second/
5. /folder/other_subfolder/second/
6. /folder/subfolder/second/
7. /folder/other_subfolder/third/
8. /folder/other_subfolder/third/
9. /folder/subfolder/third/

But why does it end up showing some files twice?

If you are still having trouble, please post a link to your current code.

I see no duplication in the above list?

Recursivity in Hugo:

4. /folder/other_subfolder/second/
5. /folder/other_subfolder/second/

and

7. /folder/other_subfolder/third/
8. /folder/other_subfolder/third/