Variables¶
Variables allows you to enter a string that references a key/value pair stored in the mkdocs.yml
file. This allows you to change the value in the mkdocs.yml
file and have that variable applied to all topics that reference it when you build your site.
A great use for variables is content that changes, like a version number, a copyright date, or product names.
Using Variables¶
-
Install the MkDocs Macros plugin using pip.
-
In the
mkdocs.yml
file, add the following information. -
In the
mkdocs.yml
file, create your key/value pair where the key will be used in your variable and the value is what replaces the variable when you publish your site or run it locally. In the example below,version
is the key and1.0
is the value. -
In a topic, use
{{ config.extra.<key> }}
where<key>
is the key you created in themkdocs.yml
file.Example: