Nesting Content

Sorry if this has been addressed, but here goes.

I have a section for products. I want to group articles that are related to that product “underneath” the product page. To clarify, here’s what the full path to one of the articles might look like:

/product/pet_rock/articles/care_and_feeding

I’d like to group the articles underneath the product section, since each product might have a very similarly named article (e.g. getting-started).

I imagine that the directory structure might look something like this:

content/
  product/
    pet-rock/
      article/
        care-and-feeding.md

I’m not sure where the actual product page would go (maybe content/product/pet-rock.md?)

Is this possible? And, what would my content directory structure look like?

Thanks!

You’re on the right track. That sounds like it would work. You can also create content/product/pet-rock/index.md for the product page.

What are your thoughts about being able to display the subset of articles that are nested underneath the product? Would I need to wire them up with some sort of tag/value in the articles’ frontmatter, or is there a way to get an array of pages that sit beneath a certain path?

I have a site that’s similar and it works well (you can set the layout in the front matter, too).

My issue is that this structure:

content/
  product/
    pet-rock/
      article/
        care-and-feeding.md

…generates some 0 byte HTML files:

product.html
product/petrock.html
product/petrock/article.html

(Worth noting: I have ugly URLs on because we have some htaccess rules set up already.)

@emarthinsen, it sounds like you need to use taxonomies.

Cool. I’ll give that a shot.

If I understand correctly, sounds like you are trying to do more or less what I was trying to do when I asked this question:

As @moorereason suggested, I ended up going with taxonomies as Hugo only generates a list view for the top level section (‘product’ in your case).

Interesting aside: as my site navigation depends only on the taxonomies now, I decided to use the ‘redundant’ product list view to implement search functionality with the excellent isotope.js used to filter the list of all products by whatever the user types in the search box. Works pretty well and almost instant results for my use case (500 products)!