gohugoio/hugo · error

is not a valid resample filter

Error message

%q is not a valid resample filter

What it means

Returned by the DecodeConfig buildConfig closure when imaging.resampleFilter is not a key in the imageFilters map. Note the message prints the zero-value filter variable (the failed map lookup result) rather than the input string, so the message text may show the resampling zero value -- a known diagnostic quirk. Valid filters include box, lanczos, linear, nearestneighbor, catmullrom, etc.

Solutions

  1. Use a valid resample filter: Box, NearestNeighbor, Linear, Hermite, MitchellNetravali, CatmullRom, BSpline, Gaussian, Lanczos, Hann, Hamming, Blackman, Bartlett, Welch, or Cosine.
  2. Pick CatmullRom if you wanted bicubic-quality downscaling.
  3. Leave it unset to keep the default Box.

Example fix

// before
[imaging]
resampleFilter = "bicubic"

// after
[imaging]
resampleFilter = "CatmullRom"
Defensive patterns

Strategy: validation

Validate before calling

var validFilters = map[string]bool{"box": true, "nearestneighbor": true, "linear": true, "hermite": true, "mitchellnetravali": true, "catmullrom": true, "bspline": true, "gaussian": true, "lanczos": true, "hann": true, "hamming": true, "blackman": true, "bartlett": true, "welch": true, "cosine": true}
func isValidFilter(s string) bool { return validFilters[strings.ToLower(s)] }

Type guard

func isValidResampleFilter(s string) bool {
    valid := map[string]bool{"box": true, "nearestneighbor": true, "linear": true, "hermite": true, "mitchellnetravali": true, "catmullrom": true, "bspline": true, "gaussian": true, "lanczos": true, "hann": true, "hamming": true, "blackman": true, "bartlett": true, "welch": true, "cosine": true}
    return valid[strings.ToLower(s)]
}

Prevention

When it happens

Trigger: Setting [imaging] resampleFilter = "bicubic" or any name not in the recognised set. The lookup imageFilters[input] returns found=false and this error fires.

Common situations: Expecting a filter name like 'bicubic' or 'cubic' that is not provided (Hugo uses CatmullRom as the bicubic-equivalent); a typo; a filter name from a different library.

Related errors


AI-assisted analysis of gohugoio/hugo@52c9bd7908 (2026-08-09). Data as JSON: /api/errors/d549dbedb147e497. Report an issue: GitHub.

Appendix: source

Thrown at resources/images/config.go:229

			return i, nil, err
		}

		i.BgColor, err = hexStringToColorGo(i.Imaging.BgColor)
		if err != nil {
			return i, nil, err
		}

		if i.Imaging.Anchor != "" {
			anchor, found := anchorPositions[i.Imaging.Anchor]
			if !found {
				return i, nil, fmt.Errorf("invalid anchor value %q in imaging config", i.Imaging.Anchor)
			}
			i.Anchor = anchor
		}

		filter, found := imageFilters[i.Imaging.ResampleFilter]
		if !found {
			return i, nil, fmt.Errorf("%q is not a valid resample filter", filter)
		}

		i.ResampleFilter = filter

		return i, i.Imaging, nil
	}

	ns, err := config.DecodeNamespace[ImagingConfig](in, buildConfig)
	if err != nil {
		return nil, err
	}
	return ns, nil
}

func DecodeImageConfig(options []string, defaults *config.ConfigNamespace[ImagingConfig, ImagingConfigInternal], sourceFormat Format) (ImageConfig, error) {
	var (
		c   ImageConfig = newImageConfig()
		err error

View on GitHub (pinned to 52c9bd7908)