{"record":{"id":"a6e0cfa65261bc46","repo":"gohugoio/hugo","slug":"imaging-webp-compression-must-be-one-of-lossy-or-l","errorCode":null,"errorMessage":"imaging.webp.compression must be one of lossy or lossless, got %q","messagePattern":"imaging\\.webp\\.compression must be one of lossy or lossless, got %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"resources/images/config.go","lineNumber":788,"sourceCode":"\t}\n\tif c.Compression == \"\" {\n\t\tc.Compression = defaultCompression\n\t}\n\tif c.Quality == 0 {\n\t\tc.Quality = 75\n\t}\n\n\tc.Hint = strings.ToLower(c.Hint)\n\tc.Compression = strings.ToLower(c.Compression)\n\n\tif c.Hint != \"\" && !hints[c.Hint] {\n\t\treturn fmt.Errorf(\"imaging.webp.hint must be one of picture, photo, drawing, icon, or text, got %q\", c.Hint)\n\t}\n\tif c.Method < 0 || c.Method > 6 {\n\t\treturn fmt.Errorf(\"imaging.webp.method must be between 0 and 6, got %d\", c.Method)\n\t}\n\tif c.Compression != \"\" && !compressionMethods[c.Compression] {\n\t\treturn fmt.Errorf(\"imaging.webp.compression must be one of lossy or lossless, got %q\", c.Compression)\n\t}\n\tif c.Quality < 1 || c.Quality > 100 {\n\t\treturn fmt.Errorf(\"imaging.webp.quality must be between 1 and 100 inclusive, got %d\", c.Quality)\n\t}\n\treturn nil\n}\n","sourceCodeStart":770,"sourceCodeEnd":795,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/resources/images/config.go#L770-L795","documentation":"Validates the WebP compression method after lowercasing and fallback. Must be 'lossy' or 'lossless' (defined in compressionMethods). If unset, inherits the global compression, then defaults to 'lossy'. Only checked when non-empty after resolution.","triggerScenarios":"Setting imaging.webp.compression (or the global imaging.compression) to any string other than lossy or lossless. Case-insensitive.","commonSituations":"Typo 'losless'; 'high'; using a value from a different encoder.","solutions":["Set imaging.webp.compression to 'lossy' or 'lossless'.","Omit the key to use the default 'lossy'.","WebP lossless is good for logos, icons, and screenshots with sharp edges and few colors."],"exampleFix":"# before (hugo.toml)\n[imaging.webp]\ncompression = \"high\"\n\n# after\n[imaging.webp]\ncompression = \"lossy\"","handlingStrategy":"validation","validationCode":"// Validate WebP compression\nfunc validateWebpCompression(c string) error {\n    c = strings.ToLower(c)\n    if c != \"\" && c != \"lossy\" && c != \"lossless\" {\n        return fmt.Errorf(\"invalid webp compression %q; valid: lossy, lossless\", c)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use 'lossy' for photos; 'lossless' for UI graphics and screenshots.","When using lossless, the quality setting has no effect — you can omit it.","The value is case-insensitive but lowercase is the convention."],"tags":["hugo","imaging","webp","config-validation"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}