{"record":{"id":"2e0c3f744cf28696","repo":"gohugoio/hugo","slug":"failed-to-parse-markdown-attributes-you-may-need","errorCode":null,"errorMessage":"failed to parse Markdown attributes; you may need to quote the values","messagePattern":"failed to parse Markdown attributes; you may need to quote the values","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"markup/goldmark/codeblocks/render.go","lineNumber":166,"sourceCode":"\t\t\tif attrEndIdx == -1 && char == '{' {\n\t\t\t\tattrStartIdx = idx\n\t\t\t}\n\t\t\tif attrStartIdx != -1 && char == '}' {\n\t\t\t\tattrEndIdx = idx\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tif attrStartIdx != -1 && attrEndIdx != -1 {\n\t\t\tn := ast.NewTextBlock() // dummy node for storing attributes\n\t\t\tattrStr := infostr[attrStartIdx : attrEndIdx+1]\n\t\t\tif attrs, hasAttr := parser.ParseAttributes(text.NewReader(attrStr)); hasAttr {\n\t\t\t\tfor _, attr := range attrs {\n\t\t\t\t\tn.SetAttribute(attr.Name, attr.Value)\n\t\t\t\t}\n\t\t\t\treturn n.Attributes(), \"\", nil\n\t\t\t} else {\n\t\t\t\treturn nil, string(attrStr), errors.New(\"failed to parse Markdown attributes; you may need to quote the values\")\n\t\t\t}\n\t\t}\n\t}\n\treturn nil, \"\", nil\n}\n","sourceCodeStart":148,"sourceCodeEnd":172,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/markup/goldmark/codeblocks/render.go#L148-L172","documentation":"Returned by getAttributes in markup/goldmark/codeblocks/render.go:166 when a fenced code block's info string contains a {...} attribute block that Hugo's attribute parser (parser.ParseAttributes) rejects. The hint suggests quoting values, the most common cause.","triggerScenarios":"Authoring a fenced code block with attribute syntax whose values are unquoted/problematic, e.g. ```go {lineNo=.} or ```bash {id=a b} (space breaks parsing). getAttributes runs during Goldmark code-block rendering.","commonSituations":"Adding Hugo code-block attributes (line numbers, IDs, options) and forgetting quotes around a value, using an unsupported attribute syntax, or a stray '{' in the info string that looks like attributes.","solutions":["Quote the attribute values, e.g. ```go {lineNos=\"true\"} .","Verify attribute names are valid (identifiers) and values are quoted strings or booleans.","If the '{' is literal (not attributes), move it into the code body or remove it from the info string.","Reproduce with a minimal fence to confirm which attribute breaks parsing."],"exampleFix":"// before\n```go {lineNos=true opt=un quoted}\n// after\n```go {lineNos=\"true\" opt=\"quoted\"}","handlingStrategy":"validation","validationCode":"// Quote code-fence attribute values; validate before relying on them.\n// Prefer: ```go {lineNos=\"true\"}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always quote attribute values in code-fence info strings.","Avoid stray '{' in the info string after the language.","Reproduce with a minimal fence to isolate the bad attribute."],"tags":["markdown","goldmark","codeblock","attributes"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}