{"id":"e05d851bffdf9b39","repo":"gohugoio/hugo","slug":"width-or-height-are-not-supported-for-this-action","errorCode":null,"errorMessage":"width or height are not supported for this action","messagePattern":"width or height are not supported for this action","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"resources/images/config.go","lineNumber":329,"sourceCode":"\t\t\t\t}\n\t\t\t} else {\n\t\t\t\treturn c, errors.New(\"invalid image dimensions\")\n\t\t\t}\n\t\t}\n\t}\n\n\tswitch c.Action {\n\tcase ActionCrop, ActionFill, ActionFit:\n\t\tif c.Width == 0 || c.Height == 0 {\n\t\t\treturn c, errors.New(\"must provide Width and Height\")\n\t\t}\n\tcase ActionResize:\n\t\tif c.Width == 0 && c.Height == 0 {\n\t\t\treturn c, errors.New(\"must provide Width or Height\")\n\t\t}\n\tdefault:\n\t\tif c.Width != 0 || c.Height != 0 {\n\t\t\treturn c, errors.New(\"width or height are not supported for this action\")\n\t\t}\n\t}\n\n\tif err := c.init(defaults.Config, sourceFormat); err != nil {\n\t\treturn c, err\n\t}\n\n\tif mainImageVersionNumber > 0 {\n\t\toptions = append(options, strconv.Itoa(mainImageVersionNumber))\n\t}\n\n\tif v := formatVersionNumbers[c.TargetFormat]; v > 0 {\n\t\toptions = append(options, \"tfv\"+strconv.Itoa(v))\n\t}\n\n\tusesSmartCrop := c.Anchor == SmartCropAnchor && (c.Action == ActionCrop || c.Action == ActionFill)\n\tif smartCropVersionNumber > 0 && usesSmartCrop {\n\t\toptions = append(options, strconv.Itoa(smartCropVersionNumber))","sourceCodeStart":311,"sourceCodeEnd":347,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/resources/images/config.go#L311-L347","documentation":"Actions other than crop/fill/fit/resize (e.g. plain processing/format conversion via images.Process, or filters) operate on the image at its original size. Hugo rejects width/height tokens there to fail fast on options that would be silently ignored.","triggerScenarios":"{{ $img.Process \"600x400 webp\" }} or any non-resizing action whose option string contains a dimensions token — the parser sets Width/Height, then the default switch branch rejects them.","commonSituations":"Assuming images.Process accepts sizes like Resize does; copying an option string from a .Fill call into a .Process/.Filter call; a stray 'x'-containing token being parsed as dimensions.","solutions":["Remove the WIDTHxHEIGHT token from the option string for this action.","If you want to resize AND convert, include the action in Process: {{ $img.Process \"resize 600x400 webp\" }}.","Alternatively chain calls: {{ ($img.Resize \"600x400\").Process \"webp\" }}."],"exampleFix":"<!-- before -->\n{{ $img.Process \"600x400 webp\" }}\n<!-- after -->\n{{ $img.Process \"resize 600x400 webp\" }}","handlingStrategy":"validation","validationCode":"if action == \"\" && (w > 0 || h > 0) {\n    return errors.New(\"dimensions not allowed for this action\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Don't pass width/height in specs for actions that ignore them (e.g. Filter/format-only operations)","Build specs per-action rather than reusing one generic \"WxH ...\" string everywhere","Lint template image partials for stray dimension tokens on non-resizing actions"],"tags":["hugo","image-processing","template","validation"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}