gohugoio/hugo · error
no pageOutput
Error message
no pageOutput
What it means
Panic in pageState.outputFormat(): ps.pageOutput is nil when the output format is requested. pageOutput holds the current output-format-specific rendering state; a nil value means the page was never assigned an active output (e.g. it has no matching output format for the current site, or shiftToOutputFormat was not run).
Source
Thrown at hugolib/page.go:841
}
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()
}
if ps.Path() != "" {
return ps.Path()
}
View on GitHub (pinned to 52c9bd7908)
Solutions
- Check the page's 'outputs' front matter / site outputs config includes the format you render for.
- Avoid calling output-format-dependent methods on pages that may be headless or filtered; guard with IsPage/IsSection and output checks.
- If embedding Hugo, ensure shiftToOutputFormat runs before consuming output.
- Report a Hugo issue if a normal build hits this on a published page.
Example fix
{{/* before: pageOutput nil for a format not in outputs */}}
{{ .Permalink }}
{{/* after: ensure outputs include the format, e.g. hugo.toml */}}
[outputs]
home = ['html','rss']
page = ['html'] Defensive patterns
Strategy: validation
Validate before calling
// Ensure the page has an active output format before calling output-dependent methods.
// hugo.toml: include the format in [outputs] for the page kind.
// Templates: guard with {{ if .OutputFormats.Get "html" }} ... {{ end }} before Permalink. Prevention
- Keep needed formats in the page's 'outputs' config.
- Avoid output-format methods on headless pages.
- Run shiftToOutputFormat before consuming output (embedded use).
- Report stock-Hugo reproducers upstream.
When it happens
Trigger: Requesting Permalink/RelPermalink/output format on a page whose pageOutput was never set, or whose output formats were all disabled/filtered out. A page rendered for an output format not in its outputs list. Accessing output-format-dependent fields before rendering begins.
Common situations: Configuring outputs to exclude a format that a template then references. A headless page accessed in a context expecting a published output. A render hook or shortcode run before the page's output is selected.
Related errors
- pageOutput is nil for output idx %d
- no site
- wrapError with nil
- ContentMediaType not set
- pageMeta.pageMetaSource.pi must be set before creating cache
AI-assisted analysis of gohugoio/hugo@52c9bd7908 (2026-08-09).
Data as JSON: /api/errors/6c4cb31515ead7d5.
Report an issue: GitHub.