This guide explains how to configure which programming languages are available for syntax highlighting in Discourse.
Required user level: Administrator
Syntax highlighting enhances readability in code blocks by applying formatting based on the programming language. You can customize the languages available for syntax highlighting in Discourse.
Configuring the highlighted_languages site setting
To configure the list of programming languages for syntax highlighting:
- Navigate to the Admin panel.
- Go to
Config→Content→Posts and Topics. - Find the
highlighted_languagessite setting.
In this setting, you can define which languages will be available for syntax highlighting. Enter the names of the languages you want to support, separated by commas.
Related settings
There are two additional site settings related to syntax highlighting, found in the same area:
-
default_code_lang— The default language applied to code blocks when no language is specified. Defaults toauto, which attempts to detect the language automatically. -
autohighlight_all_code— When enabled, applies syntax highlighting to all<code>blocks, even those without a language class specified. Defaults to off.
Adding support for additional languages
If your desired language is not bundled with highlight.js, you can add it via a theme component using the api.registerHighlightJSLanguage() plugin API. Below are the steps to achieve this:
- Locate a module for your language: Find a highlight.js language definition that supports the language you want to add. For example:
- Solidity:
https://github.com/highlightjs/highlightjs-solidity - Supercollider:
https://github.com/highlightjs/highlightjs-supercollider
- Integrate the module using a theme component:
- Obtain the HighlightJS language definition for the desired language.
- Create a new theme component in Discourse.
- In the theme component’s JavaScript, use the plugin API to register the language:
api.registerHighlightJSLanguage("languageName", languageDefinitionFunction); - See Install a new language for Highlight.JS via a theme component for a complete example.
Last edited by @SaraDev 2024-07-16T22:41:30Z
Check document
Perform check on document:

