Basic questions about template composure

Hi.
Hugo beginner here, with some programming background, good knowledge about HTML, CSS, http etc.

I understand that the final page is composed of several templates. Usually the _default/single.html or _default/list.html file is composed into _default/baseof.html, probably with some other like head, header, footer and so on. So far so good.

Since I have a hard time understanding the template lookup rules, I modified the single.html and list.html files from the theme I use (PaperMod). I simply included a paragraph containing a single letter S or L to see which template was used to produce the output.

To my surprise, most pages in my testing website do not make use of any of those two (single, list). I thought it had to be one of those two, unless I override the type in frontmatter (which I didn’t).

The layouts/_default dir of the theme does have some more files like search.html and terms.html, but I am pretty sure that these are not used because I do not see the content of these files.

So where does the output come from, which template was used? And how can I fΓ­nd that out by myself?

Here is the dir structure I have right now. Only two files show that they use single/list and baseof. All other files display also fine, but do not show my additions to identify the template. The other layouts/_default dir is empty except for some shortcodes I use.

content
β”œβ”€β”€ about
β”‚  └── index.md <- (uses 'single.html')
β”œβ”€β”€ ci-v
β”‚  β”œβ”€β”€ _index.md
β”‚  β”œβ”€β”€ changelog.md
β”‚  β”œβ”€β”€ ci-v bus adressing.md
β”‚  β”œβ”€β”€ general command structure.md
β”‚  β”œβ”€β”€ introduction.md
β”‚  └── principle of operation.md
β”œβ”€β”€ index.md <- (uses 'list.html')
β”œβ”€β”€ kiwisdr
β”‚  └── index.md
└── posts
  β”œβ”€β”€ Vortrag SDR EinfΓΌhrung GPN 2023.md
  └── Vortrag SDR EinfΓΌhrung SDR Academy.md

Cheers,
Ekki

to see the list of templates used you may use --templateMetrics for a list of unused templates --printUnusedTemplates

The template chain is not exposable OOTB.

A common workaround is to use the plain old print debugger adding something like that to the beginning of a layout, block or partial:

unfortunately you will have to hardcode the β€œTEMPLATE_NAME” within each file, there’s no method to get the current template name.

{{- warnf "%s - %s" . "TEMPLATE_NAME" -}}
1 Like