A MkDocs plugin that injects the mkdocs.yml extra variables into the markdown template
Slowing down. Last release over 2 years ago, little activity since. Fine for existing code; think twice for a new project.
pip install mkdocs-markdownextradata-pluginmkdocs-markdownextradata-plugin
A MkDocs plugin that injects the mkdocs.yml extra variables into the markdown template
usecase
As a user with variables that need to be inserted at the markdown level, not the template level.
I need a mkdocs plugin that will inject my `extras` variables into the markdown template before it gets rendered to html.
So that I can build my markdown pages with different values for images, urls, client_names, etc.
Installation
Note: This package requires MkDocs version 0.17 or higher.
Install the package with pip:
pip install mkdocs-markdownextradata-plugin
Enable the plugin in your mkdocs.yml:
plugins:
- search
- markdownextradata: {}
You are then able to use the mkdocs extra: {} hash to pass context data into your files
Note: If you have no
pluginsentry in your config file yet, you'll likely also want to add thesearchplugin. MkDocs enables it by default if there is nopluginsentry set, but now you have to enable it explicitly.
Features
Use Extra Variables in your markdown files
The variables you define in the mkdown.yml extra: slot will become available in your templates
site_name: My fantastic site
plugins:
- search
- markdownextradata
extra:
customer:
name: Your name here
web: www.example.com
salt: salt.example.com
and then in your *.md files
{{ customer.name }}
<a href="{{ customer.web }}">{{ customer.web }}</a>
Using external data files
If the extra: {} hash is not enough for your data then you are able to make use of external yaml files to provide that context data
plugins:
- search
- markdownextradata:
data: path/to/datafiles
or if you have multiple locations provide a comma (,) separated list of locations