Zalgorithm

Printing debug information from Hugo templates to the terminal

The warnf and errorf functions print information to the terminal that’s running hugo server:

{{ warnf "Debug: .LinkTitle = %v" .LinkTitle }}
{{ warnf "Debug: context = %#v" . }}

warnf prints a warning message, errorf prints an error and stops the build. These are (I think) Hugo functions, not Go functions. But they’re based on the Go fmt package.

Useful formatting verbs:

References

Hugo Documentation. “fmt.Warnf.” March 5, 2025. https://gohugo.io/functions/fmt/warnf/.

Go Documentation. “fmt.” December 2, 2025. https://pkg.go.dev/fmt.

Tags: