{"id":"f655c0c5c0a80375","repo":"gohugoio/hugo","slug":"format-q-not-supported-f655c0","errorCode":null,"errorMessage":"format %q not supported","messagePattern":"format %q not supported","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"resources/images/codec.go","lineNumber":165,"sourceCode":"\t\t\t\"hint\":         conf.Hint,\n\t\t}\n\t\treturn d.avif.Encode(w, img, opts)\n\tcase WEBP:\n\t\t// Convert bool to int because the C code reads it as a number.\n\t\tuseSharpYuvInt := 0\n\t\tif conf.UseSharpYuv {\n\t\t\tuseSharpYuvInt = 1\n\t\t}\n\t\topts := map[string]any{\n\t\t\t\"compression\": conf.Compression,\n\t\t\t\"quality\":     conf.Quality,\n\t\t\t\"hint\":        conf.Hint,\n\t\t\t\"useSharpYuv\": useSharpYuvInt,\n\t\t\t\"method\":      conf.Method,\n\t\t}\n\t\treturn d.webp.Encode(w, img, opts)\n\tdefault:\n\t\treturn fmt.Errorf(\"format %q not supported\", conf.TargetFormat)\n\t}\n}\n\nfunc (d *Codec) DecodeFormat(f Format, r io.Reader) (image.Image, error) {\n\td.debugl.Log(\n\t\tlogg.StringFunc(\n\t\t\tfunc() string {\n\t\t\t\treturn fmt.Sprintf(\"Decoding image from format %s\", f)\n\t\t\t},\n\t\t),\n\t)\n\tswitch f {\n\tcase JPEG, PNG:\n\t\t// We reworked this decode/encode setup to get full WebP support in v0.153.0.\n\t\t// In the first take of that we used f to decide whether to call png.Decode or jpeg.Decode here,\n\t\t// but testing it on some sites, it seems that it's not uncommon to store JPEGs with PNG extensions and vice versa.\n\t\t// So, to reduce some noise in that release, we fallback to the standard library here,\n\t\t// which will read the magic bytes and decode accordingly.","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/resources/images/codec.go#L147-L183","documentation":"Codec.Encode switches on the target image format (JPEG, PNG, GIF, TIFF, BMP, AVIF, WEBP); an unrecognized conf.TargetFormat falls through to this error. It is a guard for an unsupported output format reaching the encoder — normally the format string in an image-processing spec is validated earlier, so this indicates an unsupported conversion target.","triggerScenarios":"An image operation whose options request a target format outside the supported set — e.g. an unsupported format token in `.Process`/`.Resize` option strings, or internal Format values not wired to an encoder.","commonSituations":"Asking Hugo to output SVG, HEIC, or another format it can't encode; typos in the format token of a processing spec; older Hugo versions lacking a newer format (webp/avif) that a theme's templates request.","solutions":["Use a supported target format in the processing spec: jpg, png, gif, tiff, bmp, webp, or avif (e.g. `.Resize \"600x webp\"`).","Upgrade Hugo if the theme requests webp/avif and your version predates their encoder support.","Check the theme's image partials for the format token being passed and correct any typo."],"exampleFix":"// before\n{{ $img := $img.Resize \"600x heic\" }}\n// after\n{{ $img := $img.Resize \"600x webp\" }}","handlingStrategy":"validation","validationCode":"var encodable = map[string]bool{\"jpg\": true, \"jpeg\": true, \"png\": true, \"gif\": true, \"tif\": true, \"tiff\": true, \"bmp\": true, \"webp\": true}\nif !encodable[strings.TrimPrefix(strings.ToLower(ext), \".\")] {\n    return fmt.Errorf(\"cannot encode to %q\", ext)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate requested target formats against the supported set before image processing","Normalize extensions (lowercase, strip dot) before comparing","Reject unknown formats at config-load time rather than mid-build"],"tags":["hugo","images","format","encode","templates"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}