gohugoio/hugo · error
failed to resolve output formats %v: %w
Error message
failed to resolve output formats %v: %w
What it means
During PageConfigLate.Compile, the page's `outputs` list from front matter (or a content adapter) is resolved against the site's configured output formats by name. If any name doesn't match a defined output format, GetByNames fails and Hugo aborts with this error, listing the requested names, because it cannot render the page to an unknown format.
Source
Thrown at resources/page/pagemeta/page_frontmatter.go:457
// Compile sets up the page configuration after all fields have been set.
func (p *PageConfigLate) Compile(e *PageConfigEarly, logger loggers.Logger, outputFormats output.Formats) error {
if e.IsFromContentAdapter {
if err := mapstructure.WeakDecode(p.ContentAdapterData, p); err != nil {
err = fmt.Errorf("failed to decode page map: %w", err)
return err
}
}
if p.Params == nil {
p.Params = make(hmaps.Params)
} else {
hmaps.PrepareParams(p.Params)
}
if len(p.Outputs) > 0 {
outFormats, err := outputFormats.GetByNames(p.Outputs...)
if err != nil {
return fmt.Errorf("failed to resolve output formats %v: %w", p.Outputs, err)
} else {
p.ConfiguredOutputFormats = outFormats
}
}
return nil
}
// MarkupToMediaType converts a markup string to a media type.
func MarkupToMediaType(s string, mediaTypes media.Types) media.Type {
s = strings.ToLower(s)
mt, _ := mediaTypes.GetBestMatch(markup.ResolveMarkup(s))
return mt
}
type ResourceConfig struct {
Path string
Name stringView on GitHub ↗ (pinned to 8a468df065)
Solutions
- Define the missing format in site config: [outputFormats.SearchIndex] mediaType = "application/json", baseName = "searchindex".
- Fix the spelling in the page's outputs list to match a built-in or configured format name (names are matched case-insensitively but must exist).
- Remove stale format names from front matter after deleting a custom output format from config.
Example fix
# before (front matter) outputs: ["html", "searchindex"] # after: add to hugo.toml [outputFormats.searchindex] mediaType = "application/json" baseName = "searchindex"
Defensive patterns
Strategy: validation
Validate before calling
# front matter outputs must name formats defined in config --- outputs: ["html", "json"] --- # config: ensure [outputFormats.json] exists (json is built-in)
Prevention
- Only list output format names that exist (built-in or defined under [outputFormats])
- Match case/spelling exactly — `JSON` vs a custom `Calendar` name must match config
- Define custom output formats in config before referencing them in page front matter
When it happens
Trigger: Front matter like `outputs: ["html", "amp", "searchindex"]` where a name (e.g. "searchindex") isn't defined under [outputFormats] in site config; content adapters setting outputs with typos or lowercase/spelling variations of custom format names.
Common situations: Copying theme docs that assume a custom output format (JSON search index, RSS variants) without adding its [outputFormats.NAME] definition; typos like "jsonl" vs "json"; removing a custom output format from config while pages still reference it.
Related errors
- media type %q not found
- invalid output format configuration; wrong type for media ty
- failed to decode output format configuration: %w
- error processing file %q
- failed to parse file %q: %s
AI-assisted analysis of gohugoio/hugo@8a468df065 (2026-07-31).
Data as JSON: /data/errors/0ec8673973faced3.json.
Report an issue: GitHub ↗.