{"record":{"id":"1a9ef17791717180","repo":"gohugoio/hugo","slug":"imaging-webp-quality-must-be-between-1-and-100-inc","errorCode":null,"errorMessage":"imaging.webp.quality must be between 1 and 100 inclusive, got %d","messagePattern":"imaging\\.webp\\.quality must be between 1 and 100 inclusive, got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"resources/images/config.go","lineNumber":791,"sourceCode":"\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":773,"sourceCodeEnd":795,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/resources/images/config.go#L773-L795","documentation":"Validates the WebP quality after fallback resolution. If imaging.webp.quality is 0, it inherits the global imaging.quality; if that is also 0, it defaults to 75. Only relevant for lossy encoding. After resolution, quality must be 1-100 inclusive.","triggerScenarios":"Setting [imaging.webp] quality to below 1 or above 100. A value of 0 triggers fallback, not this error. The quality setting is ignored when compression is lossless.","commonSituations":"Setting quality above 100; setting quality when using lossless compression (no effect, but not an error); using JPEG-quality values without adjustment.","solutions":["Set imaging.webp.quality to a value between 1 and 100 (typical web: 70-85 for lossy).","If using lossless compression, you can omit quality since it has no effect.","Omit the key to use the default 75."],"exampleFix":"# before (hugo.toml)\n[imaging.webp]\nquality = 150\n\n# after\n[imaging.webp]\nquality = 80","handlingStrategy":"validation","validationCode":"// Validate WebP quality (0 = inherit global or default 75)\nfunc validateWebpQuality(q, globalQuality int) error {\n    resolved := q\n    if resolved == 0 { resolved = globalQuality }\n    if resolved == 0 { resolved = 75 }\n    if resolved < 1 || resolved > 100 {\n        return fmt.Errorf(\"webp quality resolves to %d, out of range [1,100]\", resolved)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["WebP quality only affects lossy encoding — for lossless, omit it.","WebP default quality 75 matches JPEG default — you can use the same value for both.","Omit the key to inherit global quality or use the default."],"tags":["hugo","imaging","webp","config-validation","quality"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}