{"record":{"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/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/resources/images/config.go#L311-L347","documentation":"The switch at config.go:318-331 only allows width/height for Resize, Crop, Fill, and Fit. For any other (or no) action, specifying a dimension is meaningless and is rejected at config.go:328-330 so that silently ignored options don't mislead users.","triggerScenarios":"Passing a `WxH` token without setting an action (no `resize`/`crop`/`fill`/`fit`), or alongside an unsupported action token, e.g. `{{ $img.Resize \"200x100 jpg\" }}` is fine but a bare `{{ $img.Process \"200x100\" }}` style call resolving to no recognized action triggers it.","commonSituations":"Typo in the action keyword so it isn't matched in `Actions`; expecting dimensions to imply a default resize; copy-pasting a dimension string intended for a resize into a format-conversion-only call.","solutions":["Add a recognized action keyword (resize/crop/fill/fit) before the dimensions.","Remove the dimension token if you only want format/quality conversion.","Check the spelling/case of the action token — options are lower-cased, so use lowercase action names."],"exampleFix":"{{/* before: action keyword missing/misspelled */}}\n{{ $img.Process \"200x100\" }}\n\n{{/* after */}}\n{{ $img.Process \"resize 200x100\" }}","handlingStrategy":"validation","validationCode":"if !slices.Contains([]string{\"resize\",\"crop\",\"fill\",\"fit\"}, action) && (width != 0 || height != 0) {\n    return errors.New(\"width or height are not supported for this action\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only resize/crop/fill/fit accept dimensions.","Spell action keywords lowercase."],"tags":["hugo","image-processing","templates","validation"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}