Types, sections, kinds and layouts

You typically don’t need to know the values of all of those values when you are starting out with Hugo. Everything is documented in the Hugo docs, but not in one place.

Let me make an attempt at simplifying these. I will explain the terms in the order of more used (i.e. one that any user will end up having to understand) to less used… from my perspective of course:

  1. Kind: IMO every user must know what “kind” any given page on their site it. Search for “Page Kinds” in doc site.

  2. Section / Type: By default, section (and type) is the first level of directory in your content directory. If you have content/posts/ all content files in there, even in nested directories will have the section and type set to “posts”.

    • For other pages where an associated content file doesn’t normally exist, like tags, categories, etc, the section and type is, crudely speaking, that first level of directory in the rendered output.
    • Search for “Sections” in documentation.
  3. Bundle type: You need to know the bundle type if you have index.md and _index.md content files. If not, ignore this.

    • See the Page Bundles documentation for more.
  4. Layout: This parameter is also left untouched most of the times. It’s present for user customization on which layout file to apply to a given content file. Again, it’s modified using a front-matter, layout. It’s implied value is “single” for page kind pages, and “list” for all other page kinds. The homepage (while would fit under “list” layout too) typically a special layout file called “index.html”.

    • The layout front-matter is documented. But may be the “implied value” needs to be better documented.
  5. Type: If left untouched, this is the same as section. But this, unlike section, can be modified using the type front-matter.

    • For homepage kind, type defaults to “page”… My understanding is that that’s for internal use in Hugo, or for legacy reasons. For homepage, section is “”. So probably Hugo sets it to a default non-empty-string value… “page”? … That said, you don’t have to worry about type as long as you are not customizing it.
    • The type front-matter is documented.
  6. ResourceType: I haven’t yet needed to care about this. As you see it defaults to “page”. Also you cannot customize this.

    • I have to confirm but I believe this is set to a non-“page” value only for non-page resources in Page Bundles. Look up the Page Bundles and Page Resources documentation. Personally I have not yet needed to care about this one. And this definitely has nothing to do with page layout lookups.

The layout lookup order follows this:

layouts/<TYPE>/<LAYOUT>.html

See the many examples in Layout Lookup in docs. That will help blend the above explanation with those examples.

6 Likes