{"record":{"id":"e5fd41258c83167a","repo":"gohugoio/hugo","slug":"imaging-webp-method-must-be-between-0-and-6-got","errorCode":null,"errorMessage":"imaging.webp.method must be between 0 and 6, got %d","messagePattern":"imaging\\.webp\\.method must be between 0 and 6, got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"resources/images/config.go","lineNumber":785,"sourceCode":"\t}\n\tif c.Hint == \"\" {\n\t\tc.Hint = defaultHint\n\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":767,"sourceCodeEnd":795,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/resources/images/config.go#L767-L795","documentation":"Validates the WebP method (quality/speed trade-off for libwebp). Must be between 0 and 6 inclusive, where 0 is fastest and 6 is slowest with best compression. The default is 2. Note this range is 0-indexed, unlike AVIF's encoderSpeed which starts at 1.","triggerScenarios":"Setting imaging.webp.method in hugo.toml to a negative number or any value above 6. There is no 0-means-default fallback for method — the default of 2 is applied at config construction, not in init().","commonSituations":"Setting method to 7 (off-by-one from the 0-6 range); confusing this 0-6 scale with AVIF's 1-10 encoderSpeed scale; setting it to 6 for smallest files and experiencing slow builds.","solutions":["Set imaging.webp.method to a value between 0 and 6. The default 2 is a good balance.","Remove the key to use the default method 2.","Only increase to 4-6 if you need the smallest possible WebP files and can tolerate longer builds."],"exampleFix":"# before (hugo.toml)\n[imaging.webp]\nmethod = 7\n\n# after\n[imaging.webp]\nmethod = 6","handlingStrategy":"validation","validationCode":"// Validate WebP method (0-6, default 2)\nfunc validateWebpMethod(method int) error {\n    if method < 0 || method > 6 {\n        return fmt.Errorf(\"webp method %d out of range [0,6]\", method)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["webp.method is 0-indexed (0-6), unlike avif.encoderSpeed which is 1-indexed (1-10).","The default of 2 is a good speed/quality balance — only change if you have measured results.","Method 6 can be 10x slower than method 0 for marginal file size improvement."],"tags":["hugo","imaging","webp","config-validation","performance"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}