Variables

Define values in docyard.yml and reference them across all Markdown pages with {{ }} syntax.

docyard.yml
variables:
  version: 2.5.0
  repo: github.com/user/project
  min_ruby: "3.0"
docs/getting-started.md
Install version {{ version }} from {{ repo }}.
Requires Ruby {{ min_ruby }} or higher.

Renders as: Install version 2.5.0 from github.com/user/project. Requires Ruby 3.0 or higher.


Nested Values

Use dot notation to access nested variables:

docyard.yml
variables:
  links:
    docs: https://docs.example.com
    api: https://api.example.com
- [Documentation]({{ links.docs }})
- [API Reference]({{ links.api }})

Code Blocks

Variables are not replaced inside fenced code blocks by default. This keeps code examples with {{ }} syntax intact.

To opt in to variable substitution in a specific code block, append -vars to the language:

```bash-vars
gem install my-gem -v {{ version }}
```

The -vars suffix is stripped from the rendered output — the block above renders as a normal bash code block with the variable replaced.

Code blocks without -vars are left untouched:

```bash
echo "{{ version }}"
```

Renders literally as 1.3.0.


Undefined Variables

References to variables that don’t exist in your config are left as-is. This prevents accidental breakage if your Markdown contains literal {{ }} syntax.


Reference

Feature Behavior
Syntax {{ name }} or {{ nested.key }}
Whitespace {{name}}, {{ name }}, {{ name }} all work
Code blocks Skipped unless language has -vars suffix
Undefined variables Left as-is
Value types Numbers and booleans converted to strings
Empty strings Replaced (results in empty output)
Included files Variables are substituted in included content
Edit this page
Last updated