{"record":{"id":"1ba4f5d94ef3fcea","repo":"gohugoio/hugo","slug":"aligny-must-be-one-of-top-center-bottom","errorCode":null,"errorMessage":"aligny must be one of top, center, bottom","messagePattern":"aligny must be one of top, center, bottom","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"resources/images/filters.go","lineNumber":109,"sourceCode":"\t\t\tcase \"color\":\n\t\t\t\tif color, ok, _ := toColorGo(v); ok {\n\t\t\t\t\ttf.color = color\n\t\t\t\t}\n\t\t\tcase \"size\":\n\t\t\t\ttf.size = cast.ToFloat64(v)\n\t\t\tcase \"x\":\n\t\t\t\ttf.x = cast.ToInt(v)\n\t\t\tcase \"y\":\n\t\t\t\ttf.y = cast.ToInt(v)\n\t\t\tcase \"alignx\":\n\t\t\t\ttf.alignx = cast.ToString(v)\n\t\t\t\tif tf.alignx != \"left\" && tf.alignx != \"center\" && tf.alignx != \"right\" {\n\t\t\t\t\tpanic(\"alignx must be one of left, center, right\")\n\t\t\t\t}\n\t\t\tcase \"aligny\":\n\t\t\t\ttf.aligny = cast.ToString(v)\n\t\t\t\tif tf.aligny != \"top\" && tf.aligny != \"center\" && tf.aligny != \"bottom\" {\n\t\t\t\t\tpanic(\"aligny must be one of top, center, bottom\")\n\t\t\t\t}\n\n\t\t\tcase \"linespacing\":\n\t\t\t\ttf.linespacing = cast.ToInt(v)\n\t\t\tcase \"font\":\n\t\t\t\tif err, ok := v.(error); ok {\n\t\t\t\t\tpanic(fmt.Sprintf(\"invalid font source: %s\", err))\n\t\t\t\t}\n\t\t\t\tfontSource, ok1 := v.(hugio.ReadSeekCloserProvider)\n\t\t\t\tidentifier, ok2 := v.(resource.Identifier)\n\n\t\t\t\tif !(ok1 && ok2) {\n\t\t\t\t\tpanic(fmt.Sprintf(\"invalid text font source: %T\", v))\n\t\t\t\t}\n\n\t\t\t\ttf.fontSource = fontSource\n\n\t\t\t\t// The input value isn't hashable and will not make a stable key.","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/resources/images/filters.go#L91-L127","documentation":"Thrown by the images.Text filter when its `aligny` option is set to a value other than \"top\", \"center\", or \"bottom\". The filter validates vertical text alignment at filter-construction time (filters.go:108-110) and panics to fail fast rather than silently rendering misaligned text. Hugo surfaces this as a build error.","triggerScenarios":"Calling images.Text with an options map whose `aligny` key holds any string besides top/center/bottom (e.g. \"middle\", \"Top\", \"baseline\"). The comparison is case-sensitive and not lowercased, unlike many other filter options.","commonSituations":"Developers coming from CSS (where `vertical-align: middle` is valid) write `aligny \"middle\"`; or they capitalize the value. Copying alignx/aligny values from a design tool that emits different vocabulary also triggers it.","solutions":["Set aligny to one of the literal strings \"top\", \"center\", or \"bottom\".","If you meant CSS middle, use \"center\".","Ensure the value is lowercase; do not rely on case-insensitivity."],"exampleFix":"// before\n{{ $filters = $filters | append (images.Text \"Hello\" (dict \"aligny\" \"middle\")) }}\n// after\n{{ $filters = $filters | append (images.Text \"Hello\" (dict \"aligny\" \"center\")) }}","handlingStrategy":"validation","validationCode":"{{ $aligny := lower (printf \"%v\" (.aligny | default \"top\")) }}\n{{ if not (in (slice \"top\" \"center\" \"bottom\") $aligny) }}\n  {{ errorf \"aligny must be top/center/bottom, got %q\" $aligny }}\n{{ end }}","typeGuard":"// ValidAligny reports whether v is an accepted vertical alignment.\nfunc ValidAligny(v string) bool {\n    switch v {\n    case \"top\", \"center\", \"bottom\":\n        return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Whitelist aligny against top/center/bottom before building the Text filter.","Treat CSS 'middle' as 'center' explicitly.","Keep alignment constants in a shared site config to avoid drift."],"tags":["image-filter","text-rendering","validation","hugo"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}