I have a footer which I use on every page. I include it in my _default/baseof.html like this:
{{ partial "footer.html" . }}
Inside this footer I want to automatically list pages from certain areas. For now I want the links to the three legal pages there. Later on, I also need to to list all pages recursively from a different area (as a flat list). But I already have trouble with the first part.
However this does not list anything when I’m on the homepage. When I am on the legal/impressum page it suddenly lists the impressum page! On the credits page it lists all three pages!
To me it suggests that Hugo is building the list of pages only while rendering the pages. When rendering the homepage it hasn’t seen the legal pages. When rendering the impressum, it has only seen that one, on the credit page it has seen them all.
Obviously that’s not what I want. I would have thought that Hugo would build a list of pages and it’s metadata before actually rendering the individual pages, but that seems not to be the case. Is there a way to enforce that? Is there a different way to achieve this kind of automatic listing?
…I am unable to reproduce the problem as described:
git clone --single-branch -b hugo-forum-topic-49379 https://github.com/jmooring/hugo-testing hugo-forum-topic-49379
cd hugo-forum-topic-49379
hugo server
Huh. How odd. I can’t reproduce the problem with your checkout either. Now I need to figure out what’s different between your code and mine… Thanks for looking into it.
I don’t understand your “block” calls… at all. Legal is a list page, and should be rendered with list.html, which contains a “main” block that isn’t called from anywhere.
Ahhh! I knew it was something silly. Thank you very much for your help.
Next, I need to learn more about why Hugo differs between _index and index and why this would change the behaviour like that. But at least I now can continue to actually work on the site.
Thanks, unfortunately it does not explain why Hugo differs between those. It seems a bit tedious to have to change my index to _index whenever I decide to add a deeper level into my page hierarchy…
Rereading this, I think I might understand where my confusion comes from…
Files with resource type page include content written in Markdown […] In a leaf bundle […] these files are only accessible as page resources. In a branch bundle, these files are only accessible as content pages.
If I understand this correctly, this is the main difference. And I think this is really only relevant when you have multiple pages in one directory. I come from a system where every page is it’s own folder, so there is not much difference to me between the two.
But I guess with my content tree, I could also have the following structure instead?
legal/impressum.de.md
legal/impressum.en.md
legal/credits.de.md
legal/credits.en.md
legal/datenschutz.en.md
legal/datenschutz.de.md
legal/index.de.md
legal/index.en.md
It’s still not 100% clear why it is technically necessary to use two different filenames here. But I guess it’s a performance optimization? When I see _index I do not need to do a full directory read to find any other pages?
Why? Wouldn’t it be the same as the “hugo-is-cool” bundle here?
Yeah sure. But I am wondering why it is necessary to differentiate. An index.html in a folder (in traditional webhosting) works the same whether there are other sub directories next to it or not. I am pretty sure there is a technical reason, but I am not getting it from the docs or your explanations.
PS: it might make sense if a mod could split off this discussion to a new thread.