In any significant amount of code, it’s hard to tell where a message came from. It’s extra hard if you’re importing multiple modules. I’ve resorted to prefixing messages with the file name and a colon, but this is prone to copy/paste and file rename errors. This is akin to logging in tests without knowing which line the messages come from.
It would be useful for errors to display as something like:
ERROR 2023/04/22 14:14:41 github.com/someaccount/somemodule: layouts/partials/somemodule/foo.html: missing bar
Using Hugo for around 6 years now. There are probably two or three posts here and in the issues of hugo by myself about this. It’s an issue with the way Golang templates and modules work, and it’s not technically possible. Would be nice, though.
My “hacky” solution: Look into warnf and errorf and create your own way to drop a marker here and there to see where you are if you are developing your own modules.
But maybe things changed in the years since…
Even just printing the file name would be useful:
ERROR 2023/04/22 14:14:41 layouts/partials/somemodule/foo.html: missing bar
I would expect the file name to be known, since it’s used to execute the template.