Substitutions
Substitutions can be defined in two places:
- In the
frontmatter
YAML within a file. - Globally for all files in
docset.yml
In both cases the yaml to define them is as followed:
subs:
key: value
another-var: Another Value
If a substitution is defined globally it may not be redefined (shaded) in a files frontmatter
.
Doing so will result in a build error.
To use the variables in your files, surround them in curly brackets ({{variable}}
).
Here are some variable substitutions:
Variable | Defined in |
---|---|
Front Matter Value | Front Matter |
A key with dashes | Front Matter |
This was defined in docset.yml | docset.yml |
Substitutions are supported in code blocks but are disabled by default. Enable substitutions by adding subs=true
to the code block.
```bash subs=true
# Your code with variables
```
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.17.0-linux-x86_64.tar.gz
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.17.0-linux-x86_64.tar.gz.sha512
shasum -a 512 -c elasticsearch-7.17.0-linux-x86_64.tar.gz.sha512
tar -xzf elasticsearch-7.17.0-linux-x86_64.tar.gz
cd elasticsearch-7.17.0/
```{code} sh subs=true
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-{{version}}-linux-x86_64.tar.gz
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-{{version}}-linux-x86_64.tar.gz.sha512
shasum -a 512 -c elasticsearch-{{version}}-linux-x86_64.tar.gz.sha512
tar -xzf elasticsearch-{{version}}-linux-x86_64.tar.gz
cd elasticsearch-{{version}}/
```
echo "This was defined in docset.yml"
```bash subs=true
echo "{{a-global-variable}}"
```
echo "{{a-global-variable}}"
```bash
echo "{{a-global-variable}}"
```