List only top-level pages and branches, not sub-pages/branches

I’m re-designing a site. In addition to normal blog-type content, it will also have “tests”, some but not all of which include sub-tests (currently I’ve no need for further levels, but I can imagine wanting sub-sub-tests at some point).

My first thought was to layout content like:

content/
  /tests/
    /test1.md
    /test2.md
    /test3/
      _index.md
      subtest31.md
      subtest32.md

My goal when navigating to /tests/ is to render a listing for test1, test2, and test3, but not the subtests. Only when navigating to /tests/test3 do I want to see the subtests.

If it helps, I put up a repository at https://github.com/wrex/testsite.git.

Currently the site* at https://wrex.github.io/testsite/public/ lists all pages including subtests but not the test3 branch _index.md content, while https://wrex.github.io/testsite/public/tests/ fails to list test3 at all. Neither is what I desire.

(* Generated with Hugo v0.68.3.)

I’m fairly certain there is some simple conditional I can use in the list.html layout while ranging over .Pages to tell if I’m in a sub-section (branch?) but I’m struggling to figure it out. I also strongly suspect there is “an easier way”.

I’ve just started the redesign and don’t have that much content to port over, so I have complete freedom in how I layout the content or otherwise organize the site, by the way.

I’d like to do it “the hugo way” and with as little unusual coding as possible. I’m a novice with hugo.

Thanks in advance for any help!

Have a read about the various .Pages here: https://gohugo.io/variables/page/#pages-compared-to-sitepages

It’s probably just a {{ range .Pages }} you want in your list.html.

I would personally suggest not having .Pagination-related things in as a starting point, though. It’s easy-ish enough to add later.

Woah.

My bad: I picked the simplest theme I could find to demonstrate my issues rather than create a list.html from scratch. I’ve found it useful to create minimal examples to reproduce my issues in the past. I hadn’t intended to introduce pagination.

After creating my own layouts/_default/list.html that removes pagination, I discover that https://wrex.github.io/testsite/public/tests/ now displays exactly what I wanted.

I’ll have to wait until tomorrow to to figure out why removing .Paginator made the difference, though. My, uh, covid-immunity meds (AKA evening cocktails) seem to be taking hold.