{"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/8a468df065a75c1c7cf9f6850f32148746590ea5/resources/images/config.go#L767-L795","documentation":"WebpConfig.init validates `imaging.webp.method`, the libwebp quality/speed trade-off knob: 0 is fastest, 6 is slowest with best compression (Hugo defaults to 2). Values outside 0-6 are rejected at config load because the underlying encoder only accepts that range.","triggerScenarios":"Setting `[imaging.webp] method` in site config to a negative number or anything above 6.","commonSituations":"Assuming a 1-10 or 0-100 effort scale like other encoders (AVIF's encoderSpeed is 1-10, which invites confusion), or cranking method to 9/10 hoping for smaller files.","solutions":["Set `imaging.webp.method` to an integer between 0 and 6 (use 6 for smallest files, 0 for fastest builds).","Remove the key to use the default of 2.","If you were tuning AVIF speed, use `imaging.avif.encoderSpeed` (1-10) instead — the scales differ."],"exampleFix":"# before\n[imaging.webp]\nmethod = 9\n# after\n[imaging.webp]\nmethod = 6","handlingStrategy":"validation","validationCode":"if m := cfg.Imaging.WebP.Method; m < 0 || m > 6 {\n    return fmt.Errorf(\"webp method %d out of range [0,6]\", m)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["imaging.webp.method accepts integers 0–6 only (speed/quality tradeoff)","Omit the key to get the default rather than passing -1 or 7+","Range-check generated configs in CI"],"tags":["hugo","config","imaging","webp"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}