How does hugo know which layout to use?

Hi

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
#your-content.md
---
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