{"id":"f1e6d39e9e0f8918","repo":"gohugoio/hugo","slug":"invalid-style-s","errorCode":null,"errorMessage":"invalid style: %s","messagePattern":"invalid style: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"markup/highlight/chromastyles.go","lineNumber":56,"sourceCode":"\t// Foreground and background colors for highlighted lines, e.g. \"#fff000 bg:#000fff\".\n\tHighlightStyle string\n\n\t// Foreground and background colors for inline line numbers.\n\tLineNumbersInlineStyle string\n\n\t// Foreground and background colors for table line numbers.\n\tLineNumbersTableStyle string\n\n\t// Omit CSS class comment prefixes in the generated CSS.\n\tOmitClassComments bool\n}\n\n// ChromaStylesCSS generates a CSS stylesheet for the Chroma code highlighter.\n// This stylesheet is needed if markup.highlight.noClasses is disabled in config.\nfunc ChromaStylesCSS(opts ChromaStylesOptions) (string, error) {\n\tname := strings.ToLower(opts.Style)\n\tif !slices.Contains(styles.Names(), name) {\n\t\treturn \"\", fmt.Errorf(\"invalid style: %s\", name)\n\t}\n\tvar chromaStyle *chroma.Style\n\tif opts.Mode != \"\" {\n\t\tvar mode chroma.Mode\n\t\tswitch opts.Mode {\n\t\tcase \"light\":\n\t\t\tmode = chroma.Light\n\t\tcase \"dark\":\n\t\t\tmode = chroma.Dark\n\t\tdefault:\n\t\t\treturn \"\", fmt.Errorf(\"invalid mode: %s\", opts.Mode)\n\t\t}\n\n\t\tchromaStyle = styles.GetForMode(name, mode)\n\t\tif chromaStyle.Mode() != mode {\n\t\t\treturn \"\", fmt.Errorf(\"style %q does not have a %q mode\", name, opts.Mode)\n\t\t}\n\t} else {","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/markup/highlight/chromastyles.go#L38-L74","documentation":"`ChromaStylesCSS` in markup/highlight/chromastyles.go lowercases the requested style name and checks it against `styles.Names()` from the Chroma library. An unknown name returns this error rather than silently falling back, so a typo can't produce a stylesheet that looks wrong at runtime. Style lookup is case-insensitive but otherwise exact.","triggerScenarios":"Calling `hugo gen chromastyles --style=<name>` or the `.Style` field of `ChromaStylesOptions` with a name Chroma doesn't ship — a typo, a Pygments-only theme name, or a style removed/renamed in the Chroma version vendored by your Hugo build.","commonSituations":"Copying a style name from Pygments docs that Chroma never implemented; using a display name with spaces (`solarized dark`) instead of the Chroma id (`solarized-dark`); upgrading or downgrading Hugo across a Chroma version bump that added or renamed styles; setting `markup.highlight.style` in hugo.toml to a name valid in a newer Hugo than the one building.","solutions":["Run `hugo gen chromastyles --help` or consult `https://xyproto.github.io/splash/docs/` for the exact style ids your Hugo version supports.","Fix the id form: use hyphenated lowercase ids like `solarized-dark`, `monokailight`, `github-dark` — not spaced display names.","If the style was added in a newer Chroma, upgrade Hugo; if it was removed, pick the closest surviving style.","Also check `markup.highlight.style` in hugo.toml, since the same validated name is used for site-wide highlighting.","Note the separate `invalid mode` error just below: `--mode` accepts only `light` or `dark`."],"exampleFix":"# before\nhugo gen chromastyles --style=\"solarized dark\" > syntax.css\n\n# after\nhugo gen chromastyles --style=solarized-dark > syntax.css","handlingStrategy":"validation","validationCode":"// verify the Chroma style name before setting markup.highlight.style\n// CLI: hugo gen chromastyles --style=monokai  (fails fast on invalid names)\nvalid := styles.Names() // github.com/alecthomas/chroma/v2/styles\nif !slices.Contains(valid, styleName) {\n    return fmt.Errorf(\"invalid chroma style %q\", styleName)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pick style names from the Chroma style gallery (e.g. monokai, dracula, github)","Style names are lowercase and case-sensitive in config","Validate markup.highlight.style in CI with hugo gen chromastyles --style=<name>"],"tags":["hugo","chroma","syntax-highlighting","cli","config"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}