Code Blocks
The Mono theme uses Chroma, Hugo’s built-in syntax highlighter, which supports hundreds of languages. The syntax color themes were generated using Hugo’s CLI:
# Light theme (GitHub style)
hugo gen chromastyles --style=github > assets/css/syntax-light.css
# Dark theme (Catppuccin Mocha style)
hugo gen chromastyles --style=catppuccin-mocha > assets/css/syntax-dark.cssThese are combined in assets/css/syntax.css and automatically switch based on the site’s light/dark mode.
To use a different theme, run the command with a different --style value (see Chroma styles for options).
Inline Code
For short code within a paragraph, use backticks:
Here is an example of inline code within regular text.
Written as:
Here is an example of `inline code` within regular text.Code Blocks
For larger blocks of code, wrap with triple backticks and specify the language.
```python
def hello():
print("Hello, World!")
```Note that all code blocks include a copy button that appears on hover for easy copying.
In the following, we show examples for several languages and the resulting highlighted code blocks.
Python:
def hello():
print("Hello, World!")JavaScript:
function greet(name) {
console.log("Hello, " + name);
}Go:
package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
}Rust:
fn main() {
println!("Hello, World!");
}CSS:
.container {
max-width: 800px;
margin: 0 auto;
padding: 1rem;
}HTML:
<!DOCTYPE html>
<html>
<head>
<title>Hello</title>
</head>
<body>
<h1>Hello, World!</h1>
</body>
</html>Bash:
#!/bin/bash
echo "Hello, World!"SQL:
SELECT name, email FROM users WHERE active = true;Advanced Features
Line Numbers: Add {lineNos=table} after the language:
| |
Written as:
```python {lineNos=table}
def hello():
print("Hello")
return True
```Line Highlighting: Highlight specific lines with hl_lines=[line_numbers_comma_separated]:
| |
Written as:
```python {lineNos=table,hl_lines=[2,4]}
def example():
# This line is highlighted
x = 1
# This line is also highlighted
return x
```Diff Highlighting: Show code changes using diff syntax:
- old_value = "remove"
+ new_value = "add"
unchanged = "same"