Bundles are so confusing or I'm stupid or both


I would like to have a different layout for these URLs:

I’ve created the following /content
/product/_index.md (empty)

I’ve created the following /layout

BUT THE LAYOUT ALWAYS COMES FROM /product/list.html or /default/list.html

Why am I so dumb?

For people who find this in the future:

It remains very hard to parse the documentation for bundles (IMHO) but I guess the way this is meant to be solved is to use params…

for example - in the file /content/products/product-a.md:

layout: "analytics-platform"

then you can use the following layout-file:


hey, I agree that sometimes it is hard to parse the documentation, but one thing to remember is that you are at a stage of project development where there are several “right” answers.

a few questions: could you share your directory structure? (with more than just two products)

is there a reason why you are not doing:

├── products/
│   ├── _index.html
│   ├── product-a.md
│   ├── product-b.md
│   ├── ...
│   └── product-n.md   
├── ...

Hey Henry - yes that structure also works fine. I just wanted a separate layout for each product a/b/c…and I guess the only way to achieve that is by calling the layout param in the markdown:

layout: "analytics-platform"

Hey Henry,

I agree that it’s confusing, but you’re completely right: anything named _index.md uses the list.html template. To use the single.html template, just delete the underscore (i.e. index.md):

As a table:

content filename in page bundle layout filename
_index.md list.html
index.md single.html

So, to make it work automatically in the example you gave:

/content/product/_index.md  <-- this uses the list.html layout
/content/product/product-a/index.md  <-- this uses the single.html layout
/content/product/product-b/index.md  <-- this uses the single.html layout


Hope this helps! I’m completing my first Hugo project at the moment, and getting this worked out in my head took way longer than I would have liked. It’s there in the documentation (that table at the top of the Page Bundles page, but I think the example in the Sections page got me mixed up, since it so-directly showed something similar to what I was trying to create.

Thanks yeah. I get the single vs. list. What I was trying to achieve was a different layout file for product-a vs product-b and they were both using single.html

Does that make sense?

Oh, I understand now. Yeah, that makes sense. I haven’t tried that yet, but the approach you described (using the “layout” key in frontmatter) sounds like a good approach.

This topic was automatically closed after 16 hours. New replies are no longer allowed.