Verbose logging

We have a pretty large website (+50 languages x +500 pages) and are from time to time facing HUGO build errors because of invalid content.

We are only getting information about which template/field things are failing in – and would like a more verbose logging – especially containing information about which “content page” ” (full path and name) is causing the error.

Any good suggestions on how to do that?

Depending on the issue, https://gohugo.io/functions/errorf/ may work.

there is a –debug switch, send the output to file an look in it.
Maybe you find the faulty page.

1 Like

Thanks Maiki,
errorf is for sure usable for me - the challenge is just that I do not know up front, where in my template .html the error would occur, because the data for the page is served from a CMS system - and there could be unforseen “editorial” errors in the content received from there.
I’ve not been able to see if there would be a “simple” way to add something like
{{ if .buildError }}
{{ errorf “something…” }}
{{ end }}
… to my /layouts/_default/baseof.html, which could be an ideal place to report specific page errors.

That said: Even better would be if HUGO build would just provide information about exactly which .md file is the source of the error - and not as it is now - only information about template an position - this would be valuable information for everyone, I’d expect.

1 Like