HUGO

How to view template lookup order for a given page

Just wondering if there’s any way to view the template lookup order for a given page either via page variables or in the cli. The lookup rules are fairly complex so it’d be useful to be able to debug them.

Failing that, what would be the template lookup order for a nested section e.g. /content/about/careers/_index.md?

UPDATE: Just saw this in the docs

When we talk about a section in correlation with template selection, it is currently always the root section only ( /blog/funny-cats/mypost/ => blog ).

If you need a specific template for a sub-section, you need to adjust either the type or layout in front matter.

So I’ve specified a layout in the front-matter.

the lookup lists can be very long, read the doc here

Hugo’s Lookup Order | Hugo (gohugo.io)

you an use printf in your template to write the used template in the output files as comment.

You can use **warnf" to write anything to the logs.

This helped me to start with own templates - comparing ist to the lookup order.