How to range through pages and list the template for that page

Hi Hugoteers,

Is there an easy way to display the template that a page is using? I wanted to add a template field to my human-readable sitemap page. Any ideas?

I have tried {{ .Template }} and some other things I found in the docs, but so far not much luck. It seems to me that would be a great method to have available.



As far as I know, it’s not currently possible.

There was a debug bar developed by @JugglerX where the template being used was hardcoded Prototyping a Hugo debug bar

(@JugglerX correct me if I’m wrong on how that works)

Yeah all the code and demos are still available for the debug bar (see the thread you linked to)

But yeah its not exactly “easy” and yes it does require hardcoding the template name into each layout - Hugo has no way (that I know of) of outputting the template being used or the lookup order.

If you don’t need to see the layout being used, you can put the debug bar in the baseof.html so only 1 partial which is much easier. But the layout and lookup order is the valuable part in my opinion.

1 Like

Thanks all! Good to know. That would be a good feature to have at some point, but sure there are other things more pressing.