gohugoio/hugo · error
format not supported
Error message
format not supported
What it means
`Codec.DecodeFormat` switches on the image `Format` enum to pick the right decoder. The default arm returns this error when the requested format is not one of JPEG, PNG, GIF, TIFF, BMP, AVIF, or WEBP. It means the Format value passed in has no registered decoder.
Source
Thrown at resources/images/codec.go:222
return img, nil
}
if rs, ok := r.(io.ReadSeeker); ok {
// See issue 14288. Turns out it's not uncommon to e.g. name their PNG files with a WEBP extension.
// With the old Go's webp decoder, this didn't fail (it looked for the file header),
// but now some error has surfaced.
// To reduce some noise, we try to reset and decode again using the standard library.
_, err2 := rs.Seek(0, io.SeekStart)
if err2 != nil {
return nil, err
}
img, _, err2 = image.Decode(rs)
if err2 == nil {
return img, nil
}
}
return nil, err
default:
return nil, errors.New("format not supported")
}
}
func (d *Codec) Decode(r io.Reader) (image.Image, error) {
d.debugl.Log(
logg.StringFunc(
func() string {
return "Decoding image from unknown format"
},
),
)
rr := toPeekReader(r)
format, err := formatFromImage(rr)
if err != nil {
return nil, err
}
if format != 0 {
return d.DecodeFormat(format, rr)View on GitHub (pinned to 52c9bd7908)
Solutions
- Confirm the source image is one of the supported formats (jpeg, png, gif, tiff, bmp, avif, webp).
- If calling DecodeFormat programmatically, ensure the Format argument is set from formatFromImage detection, not left zero.
- Convert the offending asset to a supported format with an external tool before feeding it to Hugo.
Defensive patterns
Strategy: validation
Prevention
- Restrict source images to the supported formats (jpeg/png/gif/tiff/bmp/avif/webp).
- Ensure programmatic callers derive Format via formatFromImage rather than leaving it zero.
When it happens
Trigger: A code path calling `DecodeFormat` with a zero-value or unsupported `Format` constant; an image whose detected format maps to no decoder; internal callers passing an uninitialized Format field.
Common situations: Adding a new image format constant without wiring a decoder; an image file with magic bytes that don't resolve to a known Format (so format stays 0 and is passed through); corruption in format detection.
Related errors
- gif: number of frame durations does not match number of fram
- quality ranges from 1 to 100 inclusive
- invalid image dimensions
- must provide Width and Height
- must provide Width or Height
AI-assisted analysis of gohugoio/hugo@52c9bd7908 (2026-08-09).
Data as JSON: /api/errors/bcfd0115890d288e.
Report an issue: GitHub.