Server option to output templates used?

I noticed a few posts on the forums and elsewhere that people (me included) have need for explicit confirmation for which templates have been used for output. Most solutions out there seem to hack existing Hugo functionality to do this if required.

I am wondering if the need for confirmation of templates used is a need ubiquitous enough that it should be formalised? Off the top of my head I can think of a couple options that might satisfy this possible need:

  1. Flag that tells Hugo Server to output an additional HTML page that summarises the templates used by all rendered pages. Or if not an HTML page then maybe HTML comments within each rendered page.
  2. If someone has created a clean and robust enough solution (pieced together from existing Hugo functionality) then maybe it could be integrated into Hugo for a wider audience?

I just thought I would post this as a finger in the wind test to see what people think and how they might have addressed the need.


I was making a theme component at one point around this idea.

Essentially add a .Scratch var to layout files of interest, then create a tree of the partials and layouts used.

I got as far as printing the following output to the browser console:

      <head /css.html> </head /css.html>
      <head /meta.html> </head /meta.html>
    <header.html> </header.html>
    <layouts /index.html>
      <utils /foo.html> </utils /foo.html>
      <utils /bar.html> </utils /bar.html>
    </layouts /index.html>
    <footer.html> </footer.html>

based on a layout folder like this:

β”œβ”€β”€ 404.html
β”œβ”€β”€ _default
β”‚   β”œβ”€β”€ baseof.html
β”‚   β”œβ”€β”€ list.html
β”‚   └── single.html
β”œβ”€β”€ index.html
└── partials
    β”œβ”€β”€ footer.html
    β”œβ”€β”€ head
    β”‚   β”œβ”€β”€ css.html
    β”‚   └── meta.html
    β”œβ”€β”€ header.html
    β”œβ”€β”€ head.html
    └── utils
        β”œβ”€β”€ bar.html
        β”œβ”€β”€ baz.html
        └── foo.html

I’ll see if I can do some more work on it next weekend or so. Apparently I haven’t touched it since last year, so thanks for reminding me :sweat_smile:


Nice :slight_smile: I am doing it via printf of the current filename into an HTML comment manually added to all templates. On production the comments get removed by minification.

Yes. [closed] [opened 19 Oct 2016] [closed by stalebot] [closed by stalebot] [closed by stalebot]

And there are probably more.