gohugoio/hugo · error

[%s] page %q: " + format + ": %w

Error message

[%s] page %q: " + format + ": %w

What it means

The canonical page-error formatter, pageState.errorf (page.go:832-836). It prepends the language code and page path/title to a caller-supplied message and the wrapped %w, producing '[lang] page "path/title": <msg>: <cause>'. It is the shared shape for most human-facing per-page errors, so the 'message' you see is dynamically built from the format string each call site passes.

Source

Thrown at hugolib/page.go:836

	if err != nil {
		ps.s.Log.Errorln("Failed to create content converter:", err)
	}
	return ps.contentConverter
}

func (ps *pageState) errorf(err error, format string, a ...any) error {
	if herrors.UnwrapFileError(err) != nil {
		// More isn't always better.
		return err
	}
	args := append([]any{ps.Language().Lang, ps.pathOrTitle()}, a...)
	args = append(args, err)
	format = "[%s] page %q: " + format + ": %w"
	if err == nil {
		return fmt.Errorf(format, args...)
	}
	return fmt.Errorf(format, args...)
}

func (ps *pageState) outputFormat() (f output.Format) {
	if ps.pageOutput == nil {
		panic("no pageOutput")
	}
	return ps.pageOutput.f
}

func (ps *pageState) parseError(err error, input []byte, offset int) error {
	pos := posFromInput("", input, offset)
	return herrors.NewFileErrorFromName(err, ps.File().Filename()).UpdatePosition(pos)
}

func (ps *pageState) pathOrTitle() string {
	if ps.File() != nil {
		return ps.File().Filename()
	}

View on GitHub (pinned to 52c9bd7908)

Solutions

  1. Use the [lang] page "..." prefix to locate the offending content file.
  2. Act on the trailing message/cause (e.g. install a missing markup converter, fix the template).
  3. If the cause is a wrapped file-position error, open the file at the noted line/col.
Defensive patterns

Strategy: try-catch

Try / catch

if err := ps.errorf(cause, "convert %q", markup); err != nil {
    // message shaped '[lang] page "path": convert "md": <cause>'
}

Prevention

When it happens

Trigger: Any code path that calls ps.errorf(err, format, args...) — typically content-converter failures, render errors, or resource errors that should be reported with full page context. The actual tail text depends on the call site's format string.

Common situations: Failed markup conversion (asciidoc/org/pandoc external converter missing), render errors tied to a specific page, or resource resolution failures on a page. Treat the bracketed lang + page as the locator and the trailing text as the real cause.

Related errors


AI-assisted analysis of gohugoio/hugo@52c9bd7908 (2026-08-09). Data as JSON: /api/errors/620c048466d13eff. Report an issue: GitHub.