How does hugo know which layout to use?


I am learning Hugo, and I am trying to figure out, how hugo knows which layout to use?

I have read the documentation here at Hugo's Lookup Order | Hugo … But I am struggling to understand what it means…

The documentation says “Hugo takes the parameters…” Does that mean frontmatter? For example if I set Kind: SinglePage will that particular markdown page pickup the singlepage layout?

Or if I use Layout: MyLayout.html …this should pickup the myLayour.html file from the template section?

How does it know to use a single page layout or a list layout?

Thank you kindly for any thoughts, sorry if this is a dumb question. I’ve only been at hugo for a week or two…


Yes, as far as I know:

if You dont have any custom layout/template Hugo will refer that and use the _default layout as Your template

# default layout
├── _default
│   ├── baseof.html #master template
│   ├── list.html #list content
│   └── single.html # single page layout for each content
└── index.html #homepage layout

but if You have additional custom layout/template for particular section//content then Hugo will refer to Your custom layout and will ignore the other layout.

the example below is the custom layout and the front matter for a blog content. Hugo will refer this as a single page template and ignore the other layout in your theme

├── _default
│      └── blog
│           ├──  single.html # single page for blog
└── index.html #homepage layout
type: "blog"
layout:: "single"

If You have many different type of content and need different appereance then the custom layout will be very useful

meanwhile let’s wait for a more complete answer from other members in this forum


Hope this helps


And here‘s another one:

1 Like

Thanks yudi. It is becoming clear now. This has helped. Hope I can return the favour to the community at some point.

Yes, it does a great deal! Thank you. The main docs could use documentation like that. Examples are the best way to make sense of things. I read over the main documentation many times and still I wasnt even close to understanding.

This makes it crystal clear.

…and the other tip with the partials will also help alot I am sure (will try it when I am at my dev computer)…

Thanks so much, I feel like I know what is going on now :slight_smile: …its a nice feeling…

1 Like