I’m currently putting comments at the top of my partials to help me figure out where chunks are coming from:
{{ "<!-- hugo: enter skeleton/partials/banner.html -->" | safeHTML }}
After typing it dozens and dozens of times, I’m starting to think that it would be nicer to just call a function, something like {{ .TemplateName }}
instead of typing in the path + name myself. I’m finding that when I clone templates, I forget to update that comment.
Is there an existing function that returns the name of the current template? Name with path, relative to the site root, would be ideal.
If there is, the next question is how to embed multiple mustache levels? Is it possible with Go templates or must I split it up like:
{{ "<!-- hugo: enter " | safeHTML }}{{ .TemplateName }} {{ " -->" | safeHTML }}
Now that I’m thinking about it, it would be nice to have an option to have Hugo automatically add that text before and after every template call.
Edit: Added Issue #1736 for this.