gohugoio/hugo · error
failed to resolve output formats
Error message
failed to resolve output formats %v: %w
What it means
Thrown by PageConfigLate.Compile when the 'outputs' front matter list is non-empty but outputFormats.GetByNames cannot resolve one or more of the named output formats. The wrapped error is from the outputFormats lookup; the printed list is the value of p.Outputs.
Solutions
- Use only output format names that are defined in your [outputFormats] config or built-in (html, amp, rss, json, etc.).
- Define the missing custom output format under [outputFormats] and add it to the kind's outputs list.
- Remove the 'outputs' front matter key to use the site default outputs for that page kind.
Example fix
# before --- outputs: [htm] --- # after --- outputs: [html] ---
Defensive patterns
Strategy: validation
Validate before calling
valid := map[string]bool{}
for _, f := range configuredOutputFormats { valid[f.Name] = true }
for _, name := range pcfg.Outputs {
if !valid[name] { return fmt.Errorf("unknown output format %q", name) }
} Try / catch
if err := pcfg.Compile(early, logger, formats); err != nil {
return fmt.Errorf("outputs for %s: %w", path, err)
} Prevention
- Only use output format names defined under [outputFormats] or built-in.
- Define custom output formats before referencing them in 'outputs'.
- Omit 'outputs' to use the site default for the page kind.
When it happens
Trigger: Front matter sets 'outputs: [foo]' (or a content adapter sets Outputs) where 'foo' is not one of the configured output format names (e.g. html, amp, rss, json, csv).
Common situations: Typo in an output format name, referencing a custom output format that was never defined under [outputFormats], or assuming a format exists in a theme without inheriting its config.
Related errors
- failed to decode page map
- failed to decode sites from front matter
- failed to resolve media type for
- media type not found
- cannot use --renderToMemory with --destination
AI-assisted analysis of gohugoio/hugo@52c9bd7908 (2026-08-09).
Data as JSON: /api/errors/0ec8673973faced3.
Report an issue: GitHub.
Appendix: 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 52c9bd7908)