{"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/8a468df065a75c1c7cf9f6850f32148746590ea5/resources/images/config.go#L770-L795","documentation":"WebpConfig.init checks that the effective WebP compression mode (own value, else global `imaging.compression`, else the default, lowercased) is in the compressionMethods set. WebP supports exactly two encoding modes — lossy and lossless — so any other string is rejected at config load.","triggerScenarios":"Setting `[imaging.webp] compression` or the global `[imaging] compression` to anything other than \"lossy\" or \"lossless\" in hugo.toml/yaml/json.","commonSituations":"Typos like \"lossles\"/\"loseless\", numeric compression levels carried over from PNG settings, or values like \"auto\"/\"mixed\" from other WebP tooling.","solutions":["Set the compression value to exactly \"lossy\" or \"lossless\".","Remove the key to fall back to the default.","Use `imaging.webp.quality` to tune lossy output size rather than inventing compression values."],"exampleFix":"# before\n[imaging.webp]\ncompression = \"auto\"\n# after\n[imaging.webp]\ncompression = \"lossy\"","handlingStrategy":"validation","validationCode":"if c := cfg.Imaging.WebP.Compression; c != \"\" && c != \"lossy\" && c != \"lossless\" {\n    return fmt.Errorf(\"webp compression must be lossy or lossless, got %q\", c)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use only \"lossy\" or \"lossless\" for imaging.webp.compression","Reuse one shared enum check for both avif and webp compression settings","Run `hugo config` after edits to surface config errors early"],"tags":["hugo","config","imaging","webp"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}