I have a partial for a sidebar where I try to list all sections with the number of posts in each section. I can’t get the number of post for each section, it is always 0. In this test site I have 10 posts. On the third line after “Categories” it is just a test counting manually a section to be sure this partial is processed.
I finally found why it was not working and this is mind blowing for me. I often copy/paste files to keep a stable previous situation. In my layout folder I have “sections-tree.html” and “sections-tree.html.BAK” files.
For whatever reason, the two files interfere when Hugo builds. If i delete the BAK files, I get the post counts for each section. If I add it again I get 0. But this is “sections-tree.html” that is processed because I have unique content not present in BAK file.
I would not saw this if I had not made a mistake and modified the BAK file producing a build error.
Now I already searched a way to add BAK files to some ignore list in Hugo but this seems not possible outside of /content/