Cool - Thx for sharing and your very good post!
I prefer to see the chosen templates and partials as comments in the html.
Include e.g.
{{ <!-- _default/terms.html -->
| safeHTML }}
or
{{ `<!-- partials/head.meta.html -->` | safeHTML }}
in the templates and partials.
To keep track in the blocks:
{{- block "main" . }}
{{ `<!-- block main _default/baseof.html -->` | safeHTML }}
{{- partial "main.blog.date.html" . -}}
{{- partial "main.toc.single.html" . -}}
{{ `<!-- back in _default/baseof.html -->` | safeHTML }}
{{- .Content -}}
{{- end }}
I had no chance to figure out the lookup order without tracing it via those comments…
working examples:
https://raw.githubusercontent.com/it-gro/hugo-theme-w3css-basic/master/layouts/_default/terms.html
https://raw.githubusercontent.com/it-gro/hugo-theme-w3css-basic/master/layouts/partials/head.meta.html
https://raw.githubusercontent.com/it-gro/hugo-theme-w3css-basic/master/layouts/_default/baseof.html