{"record":{"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/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/resources/images/config.go#L204-L240","documentation":"Returned by the DecodeConfig buildConfig closure (images package) when imaging.anchor in the site config is non-empty but not one of the recognised anchor positions (Center, TopLeft, Top, TopRight, Left, Right, BottomLeft, Bottom, BottomRight, Smart). The anchor map is keyed by lowercased names, so case is handled, but any other string is rejected.","triggerScenarios":"Setting [imaging] anchor = \"top-left\" or anchor = \"middle\" or any value outside the set of nine positions plus \"Smart\". Fails during Hugo config load at startup.","commonSituations":"Using a CSS-style hyphenated anchor (\"top-left\"), \"centre\" (British spelling), \"centerx\", or a typo; copying config expecting a different anchor vocabulary.","solutions":["Use one of: Center, TopLeft, Top, TopRight, Left, Right, BottomLeft, Bottom, BottomRight, or Smart.","Omit the anchor setting to keep the default Smart (smartcrop).","Remember the value is lowercased internally, so case does not matter, but spelling does."],"exampleFix":"// before\n[imaging]\nanchor = \"top-left\"\n\n// after\n[imaging]\nanchor = \"TopLeft\"","handlingStrategy":"validation","validationCode":"var validAnchors = map[string]bool{\"center\": true, \"topleft\": true, \"top\": true, \"topright\": true, \"left\": true, \"right\": true, \"bottomleft\": true, \"bottom\": true, \"bottomright\": true, \"smart\": true}\nfunc isValidAnchor(s string) bool { return validAnchors[strings.ToLower(s)] }","typeGuard":"func isValidImagingAnchor(s string) bool {\n    valid := map[string]bool{\"center\": true, \"topleft\": true, \"top\": true, \"topright\": true, \"left\": true, \"right\": true, \"bottomleft\": true, \"bottom\": true, \"bottomright\": true, \"smart\": true}\n    return valid[strings.ToLower(s)]\n}","tryCatchPattern":null,"preventionTips":["Use CamelCase anchor names (TopLeft) matching the docs.","Omit anchor to default to Smart.","Avoid hyphenated or British-spelled variants."],"tags":["image-processing","config","anchor","validation"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}