{"id":"d3ed00322e2da1e9","repo":"gohugoio/hugo","slug":"invalid-anchor-value-q-in-imaging-config","errorCode":null,"errorMessage":"invalid anchor value %q in imaging config","messagePattern":"invalid anchor value %q in imaging config","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"resources/images/config.go","lineNumber":222,"sourceCode":"\t\t}\n\n\t\tif err := mapstructure.Decode(m, &i.Imaging); err != nil {\n\t\t\treturn i, nil, err\n\t\t}\n\n\t\tif err := i.Imaging.init(); err != nil {\n\t\t\treturn i, nil, err\n\t\t}\n\n\t\ti.BgColor, err = hexStringToColorGo(i.Imaging.BgColor)\n\t\tif err != nil {\n\t\t\treturn i, nil, err\n\t\t}\n\n\t\tif i.Imaging.Anchor != \"\" {\n\t\t\tanchor, found := anchorPositions[i.Imaging.Anchor]\n\t\t\tif !found {\n\t\t\t\treturn i, nil, fmt.Errorf(\"invalid anchor value %q in imaging config\", i.Imaging.Anchor)\n\t\t\t}\n\t\t\ti.Anchor = anchor\n\t\t}\n\n\t\tfilter, found := imageFilters[i.Imaging.ResampleFilter]\n\t\tif !found {\n\t\t\treturn i, nil, fmt.Errorf(\"%q is not a valid resample filter\", filter)\n\t\t}\n\n\t\ti.ResampleFilter = filter\n\n\t\treturn i, i.Imaging, nil\n\t}\n\n\tns, err := config.DecodeNamespace[ImagingConfig](in, buildConfig)\n\tif err != nil {\n\t\treturn nil, err\n\t}","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/resources/images/config.go#L204-L240","documentation":"The site-level `[imaging]` config accepts an `anchor` used for Fill crops. During decode, the value is looked up in the anchorPositions map; if it isn't a recognized anchor name the whole imaging config fails with this error. Valid values include smart, center, topleft, top, topright, left, right, bottomleft, bottom, bottomright.","triggerScenarios":"`[imaging]\\nanchor = \"middle\"` or any string not in anchorPositions in hugo.toml; note per-image spec strings hit a different path — this one is specifically the site imaging config.","commonSituations":"Guessing CSS-like names (`middle`, `top-left` with a hyphen); case is normalized elsewhere but wrong words aren't; typos like `centre`.","solutions":["Set anchor to a supported value, e.g. `smart`, `center`, `topleft`, `bottomright` (no hyphens or spaces).","Remove the anchor key to use the default (smart)."],"exampleFix":"# before\n[imaging]\nanchor = \"top-left\"\n\n# after\n[imaging]\nanchor = \"topleft\"","handlingStrategy":"validation","validationCode":"valid := map[string]bool{\"smart\": true, \"center\": true, \"topleft\": true, \"top\": true, \"topright\": true, \"left\": true, \"right\": true, \"bottomleft\": true, \"bottom\": true, \"bottomright\": true}\nif !valid[strings.ToLower(anchor)] { /* fix imaging.anchor */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set [imaging] anchor only to Smart, Center, TopLeft, Top, TopRight, Left, Right, BottomLeft, Bottom, or BottomRight","Watch for typos like 'centre' or 'top-left' — no hyphens","Check the imaging config docs rather than guessing values"],"tags":["hugo","images","imaging","config"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}