How to make a page have a specific layout?

Hi,

I currently have the following directory structure:

content
    events
    documentation
    releases
            _index.adoc
           notes
               _index.adoc

And the theme has the following structure:

layouts
    _default
        baseof.html
        list.html
        single.html
    events
        list.html
        single.html

Currently with this configuration “releases/_index.adoc” takes the style of the _default folder. This is correct.

But I would like “releases/notes/_index.adoc” to have a different style. How could I do that?

Remember that I just want what is inside the “notes” folder to have a different style, not everything inside the releases folder.

I cannot create the releases folder inside themes because then it would not work as I want.

Bye and thanks.

I think you can set the type front matter variable for that.

For example, if type is "release-notes", then Hugo uses the layouts/_default/release-notes.html template to render the file.

Much more details about how Hugo matches a type with a template is on the template lookup order page. There look for the entries that mention ‘type’, such as:

Section list for “posts” section with type set to “blog”

Hi @Jura and thanks for your help.

I have tried as you told me and it works correctly.

But, couldn’t I do something like that? Something like this:

themes
    mytheme
        layouts
           _default
           releases
               list.html
               single.html
               notes
                   list.html
                   single.html

use layout in frontmatter

Unfortunately when Hugo looks at the type of content, it either looks at the type front matter variable or the page’s top section.

In your case those sections would be events, documentation, and releases.

The notes subsection is not used to determine the content’s type.

What you can do, is set the type front matter variable of content/releases/notes/_index.adoc with a cascading front matter variable.

That way you only have to define the type setting in _index.adoc, and not in each of the separate files in the content/releases/notes/ folder.