HUGO

Ranging .Pages not working correctly for me, and inconsistent behaviour

I’m not sure if this is a bug in Hugo or an error in my code messing things up but I have a branch bundle named /categories/ at the root of my content folder that consists of nested branch bundles (some of which consist of another level of branch bundles) and leaf bundles. For each branch bundle, I only want them to list links to their direct descendants (first level) no grand-children. According to what I read in the docs, the .Pages variable should be what I need.

The problem is that Hugo seems to be skipping over my branch bundles and prefers listing leaf bundles as if I had used .RegularPagesRecursive or something. Another strange issue is that Hugo doesn’t always seem to regenerate the same thing consistently.

I’ve made a working example of my problem with the relevent code from my project to GitHub at my repo apokaliptis/hugo-pages-issue-example

In my default list.html template, I have three different range's (two of which are commented out) trying to achieve my goal, none of which work how I wanted. Another strange thing is that when that first list regenerates a second time, it will usually list what appears to be all my nested branch bundles instead. When switching between the ranges for testing Hugo will sometimes list a combination of the two. The last problem I noticed is that although Hugo will generate the nested branch bundles as a list.html, none of them list anything.

hugo v0.89.4-AB01BA6E+extended windows/amd64 BuildDate=2021-11-17T08:24:09Z VendorInfo=gohugoio

There is a very important conflict in your setup.

The name categories is reserved as it is one of the default names of Hugo Taxonomies.

Even disabling taxonomies altogether I was unable to render the list as intended.

Therefore simply change the branch bundle name to something else e.g. products and then the list will be rendered as intended with your current template code.

Ah, that makes sense. The two previous projects I’ve done with Hugo had no use of taxonomies so I’ve never thought about that. Thanks!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.