{"id":"308af3223ec3d8bc","repo":"gohugoio/hugo","slug":"invalid-highlight-option-s","errorCode":null,"errorMessage":"invalid Highlight option: %s","messagePattern":"invalid Highlight option: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"markup/highlight/config.go","lineNumber":253,"sourceCode":"\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc parseHighlightOptions(in string) (map[string]any, error) {\n\tin = strings.Trim(in, \" \")\n\topts := make(map[string]any)\n\n\tif in == \"\" {\n\t\treturn opts, nil\n\t}\n\n\tfor v := range strings.SplitSeq(in, \",\") {\n\t\tkeyVal := strings.Split(v, \"=\")\n\t\tkey := strings.Trim(keyVal[0], \" \")\n\t\tif len(keyVal) != 2 {\n\t\t\treturn opts, fmt.Errorf(\"invalid Highlight option: %s\", key)\n\t\t}\n\t\topts[key] = keyVal[1]\n\n\t}\n\n\tnormalizeHighlightOptions(opts)\n\n\treturn opts, nil\n}\n\nfunc normalizeHighlightOptions(m map[string]any) {\n\tif m == nil {\n\t\treturn\n\t}\n\n\t// lowercase all keys\n\tfor k, v := range m {\n\t\tdelete(m, k)","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/markup/highlight/config.go#L235-L271","documentation":"`parseHighlightOptions` parses a comma-separated `key=value` options string used by Hugo's highlight shortcode/function and the legacy `pygmentsOptions` site setting. Each comma-separated segment must split into exactly one key and one value on \"=\"; a segment with no \"=\" or with multiple \"=\" signs aborts parsing with this error naming the offending key.","triggerScenarios":"A `{{< highlight go \"linenos=table,hl_lines\" >}}` shortcode or `transform.Highlight`/`highlight` template call where an option segment lacks `=value`; a value itself containing \"=\" (splits into 3 parts); a trailing comma producing an empty segment; or a malformed `pygmentsOptions` string in site config.","commonSituations":"Typos in shortcode option strings (missing \"=\", using \":\" instead of \"=\"), passing space-separated instead of comma-separated options, quoting issues in templates that swallow the value, and old Pygments-era configs migrated forward with stray commas.","solutions":["Format every option as key=value, comma-separated with no trailing comma, e.g. \"linenos=table,hl_lines=2 4,linenostart=10\".","Remove or fix the segment named in the error message (it prints the bad key).","If a value needs \"=\", it isn't supported here — restructure the option or set it in site config under markup.highlight instead."],"exampleFix":"{{/* before */}}\n{{< highlight go \"linenos,hl_lines=2\" >}}\n{{/* after */}}\n{{< highlight go \"linenos=table,hl_lines=2\" >}}","handlingStrategy":"validation","validationCode":"validOpts := map[string]bool{\"style\": true, \"lineNos\": true, \"lineNumbersInTable\": true, \"hl_Lines\": true, \"linenostart\": true, \"anchorLineNos\": true, \"lineAnchors\": true, \"hl_inline\": true, \"noClasses\": true, \"tabWidth\": true, \"guessSyntax\": true, \"wrapperClass\": true}\nfor k := range userOpts {\n    if !validOpts[k] {\n        return fmt.Errorf(\"unknown highlight option %q\", k)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only pass documented highlight options in `{{< highlight >}}` shortcodes and markup.highlight config","Watch for typos in option names — the error message echoes the offending key","Validate option strings (key=value pairs) before templating them into highlight calls"],"tags":["hugo","shortcode","syntax-highlighting","config","parsing"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}