Type vs Sections? Whats the difference?

Can someone please explain the difference between a type and a section. It seems to me that a section is just a sub folder in the content directory. However it also seems like “type” is also defined this way as well. As an aside it also seems like templates are all defined in the layouts directory under a subfolder named after the section/type? Anyways thanks for your help!

If you’re familiar with WordPress, it’s the same as post format to custom post type. A section is a specific representation of an object, like a blog post. A type further segments that down to what kind of data it contains and lets you display them differently. You might just post a video link or a gallery of images, rather than a full blog post with a lot of text, so you can change up how they look while still being in the same folder structure.

2 Likes

I’m noticing that while I can set TYPE in front matter to whatever I want, if I set SECTION, it doesn’t always work. Is this a bug or feature with the latest Hugo?

  • Section is the first folder under content (content/blog => blog)
  • Section cannot be set in front matter
  • Type can be set in front matter
  • If Type isn’t set, the value of Section will be used
3 Likes

From what I’ve noticed, a Section is a Type, but defined by its directory, and implicitly sets the type for each content within the section folder.

The only use case I can think of for it is for file content organization purposes. For example, maybe you want to have top level categories, where each section is the category, but the content type still belongs to post/blog.

I personally don’t use the type attribute at all, but that would change if content would first be rendered by section then by type. I think I’ll post a feature request. (I may be missing something however)

If you are familiar with WordPress, you may think “section” as “custom post type” while “types” as “post formats”.

The sections part of the docs say that Section can be set via front matter. In practice, I’ve found the contrary to be true, as you say here, @bep. Can a content entry’s section be set via front matter or not?

What I said.

Alright. I’ve created a PR for the docs with the correction.