This class reference is valid for all Hugo and Go grammars. Exceptions are mentioned in the respective sections.
Core modes used
hljs.NUMBER_MODEhljs.QUOTE_STRING_MODEhljs.APOS_STRING_MODE(as base for string.rune)hljs.COMMENT
Standard scopes (classes)
The following standard scopes are used to style the output. Make sure your style has a definition for them.
commentUsed for opening and closing comment tags and inner text
{{/*,{{- /*,*/ -}},*/}}numberall kind of numbers
operatorUsed for the following items :
|,,,=,:=propertyUsed for dot chained words except if the chain starts with a built_in. In that case the beginning of the chain gets built_in (one or two words). see also property.method below.
With Go grammars there’s nothing like that,
a.bis a property justais not.punctuationUsed for opening and closing parenthesis of sub expressions:
(,)stringStrings (single and double quoted).
template-tagUsed for opening and closing template tags.
{{,{{-,-}},}}template-variableUsed for template variables starting with a
$(example$myVar)
New scopes (classes)
Themes out in the wild won’t have styles for these. If you do not define any for these special subclasses, Highlight.js will fallback to the parent style.
property.method(valid for Hugo only)A context, variable or built_in followed by a dot should be a method call. Target this with the
.hljs-property.method_selector.template-variable.contextThe Context – a leading
.or$.– is a special thing in Go/Hugo templating. Target this with the.hljs-template-variable.context_selector.string.rawA raw string in Go/Hugo templates is a sequence of characters enclosed in backticks. Target this with the
.hljs-string.raw_selector.string.runeA rune literal in Go/Hugo templates is a sequence of characters enclosed in single quotes. Target this with the
.hljs-string.rune_selector.
Keywords
We divide Go/Hugo keywords into the following standard scopes.
literalnot many with Hugo, just:
false,nil,truekeywordFor Hugo as documented in Hugo - go template functions
For Go as documented in Go template actions and
define1For both
urlqueryis moved to built_ins. 2built_inFor Hugo as documented in Hugo - Functions excluding the keywords from above. Both – the real namespaced function name and it’s aliases are available.
For Go as documented in Go Template-Text Predefined template functions
HINT: Keywords for Hugo are generated at build time from a recent version of the docs. For older template code bases this may result in missing highlighting ancient keywords/built_ins. The Go template keywords are manually picked from the docs.
Sub modes
The HTML grammars use XML as subLanguage. Check the official documentation for scopes used there.

