Preface: I just learned about leaf bundles and so I’m not sure if this is a bug or me using things incorrectly.
So - I’ve got a single page layout for a webpage. I wanted to experiment with having that specified as a leaf bundle as root. The content was therefore “/content/index.md”, “/content/leafa.md”, “/content/leafb.md”. Then in the layout I’d pull in those leaves as sections.
I saw some weird behavior though - I think I’ve boiled it down to hugo sometimes rendering the content using the template at “/layouts/_default/single.html” and sometimes using “/layouts/_default/list.html”.
Literally - if I build the site over and over again without changing anything else (that I know of) I can see hugo choosing single sometimes and list sometimes…
% ./reproduce_bug.sh
Sat 01 Feb 2020 10:18:30 AM MST
This is single layout
Sat 01 Feb 2020 10:18:47 AM MST
This is single layout
Sat 01 Feb 2020 10:19:05 AM MST
This is single layout
Sat 01 Feb 2020 10:19:19 AM MST
This is single layout
Sat 01 Feb 2020 10:19:25 AM MST
This is single layout
Sat 01 Feb 2020 10:19:40 AM MST
To explain that - the old site gets deleted and the site builds every (approx) half second. Then the script searches for output indicating that the single layout build was used. The list layout is almost always used, but these timestamps indicate the times when the single layout got used. I stopped right after the last timestamp there, and the first timestamp is emitted at startup…
So - single layout got used 5 times out of (maybe) 120-140.
In practice I was actually running into it being used much more often for some reason.
Am I misunderstanding how these things are supposed to work, and therefore my request is kinda ambiguous to hugo? Or is this a bug.
EDIT: hugo version - Hugo Static Site Generator v0.63.2 linux/amd64 BuildDate: 2020-01-27T19:21:07Z
The reason why this came up is if Hugo uses layouts/index.html or layouts/default/list.html as the template, there are no .Resources available. Perhaps when it is choosing to render this root leaf bundle in that way, it is actually thinking it’s a branch bundle.
Based on template lookup order documentation and the homepage template concept, it’s probably more appropriate to have a single page template at layout/index.html, but that doesn’t seem to interact well with the leaf bundle concept.
Then I’d get http://example/index.html and http://example/leaf_bundle/index.html as outputs. The leaf bundle index would get access to somecontent and someothercontent as resources when rendering.
What I mean by leaf bundle as root is, my content directory looks like:
So, following the pattern from before, I expect http://example/index.html with access to somecontent and someothercontent as resources.
EDIT: And - I do get these things. Everything works consistently and without error when I have layouts/index.html as a 0 byte file, and layouts/single.html containing my template.
As I said, I have not read your entire post. Your setup may work, but you then need to start to disable the home page generation, because as it is you end up with 2 pages in the same location. And then there is the recursive part, meaning you cannot have any other pages …
Ahh - perhaps this is the source of the behavior I was seeing. With a list and single layout template I was sometimes seeing the output at “index.html” be from list template, and sometimes see it as being from single template. It was switching back and forth… Perhaps the pages get generated in parallel, dropping files at the same location, and the last one to finish “wins”.
I understand what you mean now that you explain that, “I cannot have any other pages”. That’s what I want - this is a single page layout acting as the front door to a website. Other content has a significantly different look corresponding to entirely different themes.