{"id":"ccc60e90aef8e9a5","repo":"gohugoio/hugo","slug":"imaging-avif-encoderspeed-must-be-between-1-and-10","errorCode":null,"errorMessage":"imaging.avif.encoderSpeed must be between 1 and 10, got %d","messagePattern":"imaging\\.avif\\.encoderSpeed must be between 1 and 10, got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"resources/images/config.go","lineNumber":721,"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 = 60\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.avif.hint must be one of picture, photo, drawing, icon, or text, got %q\", c.Hint)\n\t}\n\tif c.EncoderSpeed < 1 || c.EncoderSpeed > 10 {\n\t\treturn fmt.Errorf(\"imaging.avif.encoderSpeed must be between 1 and 10, got %d\", c.EncoderSpeed)\n\t}\n\n\tif c.Compression != \"\" && !compressionMethods[c.Compression] {\n\t\treturn fmt.Errorf(\"imaging.avif.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.avif.quality must be between 1 and 100 inclusive, got %d\", c.Quality)\n\t}\n\n\treturn nil\n}\n\n// WebpConfig holds WebP-specific encoding configuration.\ntype WebpConfig struct {\n\t// Quality setting (1-100). Falls back to the global imaging.quality if unset.\n\t// Only relevant for lossy encoding.\n\tQuality int\n","sourceCodeStart":703,"sourceCodeEnd":739,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/resources/images/config.go#L703-L739","documentation":"imaging.avif.encoderSpeed sets the AVIF encoder's quality/speed trade-off, where 1 is slowest/smallest and 10 is fastest (the default). AvifConfig.init rejects any value outside 1–10 because the underlying encoder only accepts that range. Note that an explicit 0 is out of range here — there is no zero-value fallback for this field.","triggerScenarios":"Setting imaging.avif.encoderSpeed = 0, 11, or any value outside 1–10 in hugo.toml; also triggered when the field is unset and defaulting fails to apply (e.g. explicitly setting it to 0 thinking that means 'default'). Fires at config load.","commonSituations":"Assuming 0 means 'use default'; mapping from encoders with different speed scales (e.g. cavif/libaom 0-based speed settings); trying very low values and going negative.","solutions":["Set imaging.avif.encoderSpeed to a value between 1 and 10 (default is 10; staying above 5 avoids very long builds).","Remove the setting entirely to use the default.","If you wanted smaller files, use a lower speed like 5–6 rather than 0."],"exampleFix":"# before (hugo.toml)\n[imaging.avif]\nencoderSpeed = 0\n# after\n[imaging.avif]\nencoderSpeed = 10","handlingStrategy":"validation","validationCode":"if s := cfg.Imaging.AVIF.EncoderSpeed; s != 0 && (s < 1 || s > 10) {\n    return fmt.Errorf(\"imaging.avif.encoderSpeed must be 1-10, got %d\", s)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep imaging.avif.encoderSpeed within 1–10; don't reuse quality-style 1–100 values here","Note that each numeric imaging option has its own range — check docs per key","Add a config-validation step (hugo build in CI) to catch out-of-range encoder settings early"],"tags":["hugo","config","avif","image-processing","validation"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}