Feedback wanted: Nested sections: Content structure

I’m thinking mostly about here:

Which is more or less the same in the new docs:

https://hugodocs.info/content-management/types/#assigning-a-content-type

It seems a common hack has been to declare a type in a subsection’s content file front matter for filtering/sorting since a subdir under content now assumes the parent’s section (and by default, type). I think this was my line of reasoning w/r/t my earlier question about Data.Pages.

I’m not sure I follow;

  • We have .Section, which is the first folder below /content
  • Then we have .Type, which if not set in front matter, will get its value from `.Section``

I have not thought this through in its entirety, but it may be the most sane thing to keep .Section as is today (i.e. “blog”, the first root), and add some other getter to get the full slice.

It might be better if I put together a sample tree and post it in a few hours. Otherwise writing all this out will be a novel. I’ll post or DM in a few hours after work, @bep. Thanks.

have there been any improvement on the matter?

it would be a hell of a feature if we could have support for sub sections.

thank you @bep.
it seems then, that I’ve not been able to get it to work.

I have this structure:

content
├── folder
    └── subfolder
        └── _index.md

but I can’t make it work with the layout at

layouts/folder/subfolder/list.html

do you confirm it should work? if that’s the case I’ll continue testing and look into a possible my mistake.

1 Like

Nested sections cannot have their own templates.

I have workaround for this.

In _index.md I still keep both type and layout, so it is there when Hugo will support it:

type: "school"
layout: “state”

Then in /layouts/school/list.html I added:

{{ $layout := add .Params.layout “.html”}}
{{ partial $layout . }}

so in this case I added state.html to my partial layouts.

I will close this very old thread that discussed the development of this feature.

1 Like