Ranging subdirectories

This is a related post to a question someone raised 4 months ago, but could someone please explain to me why ranging subdirectories is so complicated in Hugo? Is this something that is being worked on and is just a case of Hugo still being relatively new? I need to get clear on simple functionality such as this before I can be confident about moving several projects over to Hugo.

Directory Structure

- content
    - dir1
    - dir2

Expected ranging loop to target directory 3

<div class="row">
    {{ range .Site.Pages.dir1.dir2.dir3 . }}
        <div class="col">
    {{ end }}

I personally think this is the most straightforward way to range a subdirectory but this does not currently work. I’ve had to use data json or more complex combination of where and frontmatter to achieve this which I don’t think is a very elegant solution.

You need to explain your use case better.

I don’t think so.

I don’t think that’s the case either.

.Site.Data does not look into the content/ dir… that dir is strictly for site content.

I think the problem is that you have certain assumptions… you just need to take it slow and read the docs and ask the right questions with a better tone.

Sorry I made a typo, it was .Site.Pages.dir1.dir2.dir3 what I was meant to write not .Site.Data...

My use case is this, I want to range query all the content in the dir3 subdirectory and pull {{.URL}} or {{.Title}} etc from content in this subdirectory (dir3) only.

My understanding is that .Site.Pages refers to the all the Pages in the site. Well if I want to refer to the pages in ONLY certain subdirectories wouldn’t .Site.Pages.dir1.dir2.dir3 be the right way to go about it? But this does not work.

The directory structure in content/is not available to the user (i.e. templates) for direct parsing. That directory structure is read by hugo and converted to sections, leaf/branch bundles, etc.

You can then use the section variables to do the kind of stuff you want. I believe that this comes close: