gohugoio/hugo · error

imaging.webp.quality must be between 1 and 100 inclusive, go

Error message

imaging.webp.quality must be between 1 and 100 inclusive, got %d

What it means

WebpConfig.init validates the effective WebP quality: an unset (0) value falls back to the global `imaging.quality` and then to 75, so a value that fails the 1-100 check was explicitly set out of range. Quality only affects lossy encoding.

Source

Thrown at resources/images/config.go:791

	}
	if c.Quality == 0 {
		c.Quality = 75
	}

	c.Hint = strings.ToLower(c.Hint)
	c.Compression = strings.ToLower(c.Compression)

	if c.Hint != "" && !hints[c.Hint] {
		return fmt.Errorf("imaging.webp.hint must be one of picture, photo, drawing, icon, or text, got %q", c.Hint)
	}
	if c.Method < 0 || c.Method > 6 {
		return fmt.Errorf("imaging.webp.method must be between 0 and 6, got %d", c.Method)
	}
	if c.Compression != "" && !compressionMethods[c.Compression] {
		return fmt.Errorf("imaging.webp.compression must be one of lossy or lossless, got %q", c.Compression)
	}
	if c.Quality < 1 || c.Quality > 100 {
		return fmt.Errorf("imaging.webp.quality must be between 1 and 100 inclusive, got %d", c.Quality)
	}
	return nil
}

View on GitHub ↗ (pinned to 8a468df065)

Solutions

  1. Set `imaging.webp.quality` to an integer between 1 and 100 (default 75).
  2. For maximum fidelity use `compression = "lossless"` rather than quality > 100.
  3. Remove the key to inherit the global quality or default.

Example fix

# before
[imaging.webp]
quality = 0.8
# after
[imaging.webp]
quality = 80
Defensive patterns

Strategy: validation

Validate before calling

if q := cfg.Imaging.WebP.Quality; q < 1 || q > 100 {
    return fmt.Errorf("webp quality %d out of range [1,100]", q)
}

Prevention

When it happens

Trigger: Configuring `[imaging.webp] quality` (or the inherited global `[imaging] quality`) with a negative value or one above 100.

Common situations: Using 0.0-1.0 fractional scales from JS image libraries, adding an extra digit (750), or setting -1 hoping for "auto" quality.

Related errors


AI-assisted analysis of gohugoio/hugo@8a468df065 (2026-07-31). Data as JSON: /data/errors/1a9ef17791717180.json. Report an issue: GitHub ↗.