Variables

Zolt allows you to define reusable pieces of content to maintain consistency and simplify document updates.

Local Variables

Define variables anywhere in your file:

zolt
$version = "2.0.0"
$author = "Jane Doe"
$count = 42
$enabled = true
Result

Variables defined in this block are ready to use.

Using Variables

Reference variables anywhere in your text with {$variable} :

zolt
Welcome to {$author}'s guide.
Version: {$version}
Items: {$count}
Result

Welcome to Jane Doe's guide. Version: 2.0.0 Items: 42

Global Variables

Use the $$ prefix for project-wide variables defined in zolt.yaml or global scope:

zolt
$$siteName = "My Website"
$$company = "Acme Corp"

Data Types

Arrays

zolt
$fruits = ["Apple", "Banana", "Cherry"]

First: {$fruits[0]}
Second: {$fruits[1]}
Result

First: Apple Second: Banana

Objects

zolt
$user = {name: "Alice", age: 30, city: "NYC"}

Name: {$user.name}
Age: {$user.age}
Result

Name: Alice Age: 30

Arrays of Objects

zolt
$products = [
  {name: "Laptop", price: 999},
  {name: "Mouse", price: 29},
  {name: "Keyboard", price: 79}
]

First Product: {$products[0].name}
Result

First Product: Laptop

Practical Usage

In Tables

zolt
$items = [
  {name: "Widget", qty: 5},
  {name: "Gadget", qty: 3}
]

| Item | Qty |
| :--- |---: |
:::foreach {$items as $item}
| {$item.name} | {$item.qty} |
:::
Result
ItemQty
Widget5
Gadget3

Best Practices

  1. Define variables at the top of documents for better visibility
  2. Use descriptive names ( $font_size instead of $fs )
  3. Keep global variables in your project configuration for consistency
  4. Use camelCase or snake_case consistently for variable names

© 2026 Jane Doe