Non-recursive .Paginator.Pages?

I have a multi-level hierarchy of content, and would like parent _index.md to only list direct child pages. Based on experiments, I’m getting a recursive traversal instead. How would I get a non-recursive traversal i.e. only a list of direct descendants?

Actually I would sort of expect that both options are available. If so, how?

Thanks!! Johannes.

1 Like

Hi,

What code have you tried using, what is it generating, and what do you want it to generate instead?

Better yet, do you have your sample code somewhere we can have a look at including your content structure so we are talking about the same thing in discussing what the output is?

1 Like

Here it is: https://gitlab.com/project-springtime/project-springtime.gitlab.io

The problem occurs with content/systems/_index.md, as soon as its child content/systems/vert-rdwc-1/_index.md gets renamed to content/systems/vert-rdwc-1/index.md. When I do that rename, the parent (systems) shows all .md pages recursively down. While currently those are on the same level as the child index.md (e.g. content/systems/vert-rdwc-1/construction.md), moving them into their separate directory (e.g. content/systems/vert-rdwc-1/construction/index.md) makes no difference.

The documentation seems to imply to me that the parent (content/systems/_index.md) should only show the single child, not all descendants recursively.

And ideally I’d like to decide which one I want. But even if I want recursive, I probably don’t want them as a flat list.

Is this while running hugo server? I have a feeling this is a cache thing and so may be misleading. If you rename _index.md to index.md while running hugo server you may see http://localhost:1313/systems/ reflect the child pages. However if you kill hugo server, restart, and navigate back to /systems/ you will see that the children are in fact still not listed.

I’m having a very similar issue to the one described here.

I’m trying to list pages at a single level of my content hierarchy using {{ range where .Pages.ByDate.Reverse }}. This used to only display pages for the current level of my content hierarchy (as the document indicates it should), but ever since updating to v0.57.2, this has started listing pages from lower levels of my content hierarchy.

1 Like

Regression, perhaps?

I’ve resolved my issue by changing {{ range where .Pages.ByDate.Reverse }} to {{ range where .RegularPages.ByDate.Reverse }}

Perhaps using .RegularPages in your layout file would solve your issue.

1 Like

For anyone else drawn here by the title of the discussion, the change of Pages behaviour (and introduction of RegularPages) mentioned by jedsundwall occurred in hugo 0.57. The reasons for it are explained in the release notes.

1 Like