Not necessarily in TOML, but I think you mean in terms of how you are declaring a
type and layout in your content files’ front matter.
By default, the
type for a piece of content is inherited from the the content’s section. So, the file you create for content at
content/posts/my-post.md automatically has a
posts. However, you may want to keep
my-post.md within that section because you want to rely on Hugo’s default behavior to render the page to
yoursite.com/posts/my-post, but you want it to render according to a different layout. In this case, you can specify a
type for the content that overrides the default behavior. Types are always singular.
You can then put specific layouts in a layout folder of the same name as the type (hence why it works with
mylayout). You are telling Hugo that your About page, while living inside the root content section, is of the specific
mylayout type. Further, you could even specify a layout that Hugo should use to render your About page:
date = "2017-04-17T11:01:21-04:00"
draft = false
title = "About"
type = "mylayout"
layout = "speciallayout"
In this example, Hugo will render the page according to what you create in
./themes/mytheme/layouts/mylayout/speciallayout.html. If you do not specify the layout, Hugo then looks for the the next layout in the lookup order. Here are the respective docs:
- For understanding what a
type is in Hugo:
- For understanding Hugo’s lookup order for single content templates:
- If you are unfamiliar with the lookup order in general, the following may help as well: