gohugoio/hugo · error
resource %q of media type %q does not support this method: %
Error message
resource %q of media type %q does not support this method: %s
What it means
Thrown by resourceAdapter.getImageOps() (transform.go:401-415) when the underlying target does not implement images.ImageResourceOps, i.e. the resource is not a processable image. The panic includes the resource name, media type, and explicit instructions to check support with reflect.IsImageResource / IsImageResourceProcessable / IsImageResourceWithMeta before calling image methods.
Source
Thrown at resources/transform.go:414
func (r resourceAdapter) WithResourceMeta(mp resource.ResourceMetaProvider) resource.Resource {
r.metaProvider = mp
return &r
}
func (r *resourceAdapter) getImageOps() images.ImageResourceOps {
img, ok := r.target.(images.ImageResourceOps)
if !ok {
instructions := "use reflect.IsImageResource, " +
"reflect.IsImageResourceProcessable, or " +
"reflect.IsImageResourceWithMeta to check if the resource " +
"supports this method before calling it"
msg := fmt.Sprintf(
"resource %q of media type %q does not support this method: %s",
r.Name(),
r.MediaType(),
instructions,
)
panic(msg)
}
r.init(false, false)
return img
}
// ResolveImageOpsSupport reports the ImageOpsSupport for the given resource. This can be used to determine if a resource supports image operations like Resize, Crop, etc.
func ResolveImageOpsSupport(v any) images.ImageResourceType {
r, ok := v.(resource.Resource)
if !ok {
return images.ImageResourceTypeNone
}
mt := r.MediaType()
if mt.MainType != "image" {
return images.ImageResourceTypeNone
}
_, support := images.ImageFormatFromMediaSubType(mt.SubType)
return supportView on GitHub (pinned to 52c9bd7908)
Solutions
- Use reflect.IsImageResource / IsImageResourceProcessable to guard before calling image methods.
- Confirm the resource's MediaType is an image subtype Hugo can process (jpeg/png/gif/webp/tiff/bmp).
- Note SVG is generally not raster-processable; convert or handle separately.
Example fix
// before
{{ $img := $r.Resize "100x100" }}
// after
{{ if reflect.IsImageResourceProcessable $r }}
{{ $img := $r.Resize "100x100" }}
{{ end }} Defensive patterns
Strategy: type-guard
Validate before calling
{{ if reflect.IsImageResourceProcessable $r }}
{{ $img := $r.Resize "100x100" }}
{{ else }}
{{ errorf "resource %s is not a processable image" $r.Name }}
{{ end }} Type guard
// IsProcessableImage reports whether r supports image operations.
func IsProcessableImage(r resource.Resource) bool {
return images.ResolveImageOpsSupport(r) != images.ImageResourceTypeNone
} Prevention
- Guard every image method call with reflect.IsImageResource / IsImageResourceProcessable.
- Confirm media type is an image subtype before processing.
- Handle SVG/PDF separately from raster image processing.
When it happens
Trigger: Calling an image method (Resize, Crop, Fit, Fill, Filter/Process, DecodeImage, etc.) on a resource whose media type is not an image, or whose subtype is not a supported image format. The method dispatch happens lazily inside getImageOps.
Common situations: A page bundles a PDF or SVG expecting Resize to work; a non-image resource is passed through a generic image-processing partial; or the media type is misconfigured (e.g. wrong MIME for a WebP).
Related errors
- no Resource provided in transformation
- no Key set in Resource
- failed to resolve media type for suffix %q
- failed to resolve media type for %q
- media type %q not found
AI-assisted analysis of gohugoio/hugo@52c9bd7908 (2026-08-09).
Data as JSON: /api/errors/cace3870082e7c7a.
Report an issue: GitHub.