How to config custom key-value pairs in mkdocs.yml ? #5084
-
I want to add NEW key-value pairs (like pdf_url) in mkdocs.yml, for example, repo_url: http://xxxxxx however, the
shows that WARNING - Config value 'pdf_url': Unrecognised configuration name: pdf_url. So how to config custom key-value pairs in mkdocs.yml ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The extra:
pdf_url: http://xxxxxx/ and then in your Jinja2 HTML template you can do something like this: <a href="{{ config.extra.pdf_url }}">Download the PDF</a> or maybe you want to have access to those variables in the Markdown, then maybe the https://www.mkdocs.org/user-guide/configuration/#extra |
Beta Was this translation helpful? Give feedback.
The
repo_url
is a predefined setting of the MkDocs configuration file. As far as I know, you cannot add more global key value pairs there without changing how it works. However, there is theextra
key, which allows to add any keys under there.Like so:
and then in your Jinja2 HTML template you can do something like this:
or maybe you want to have access to those variables in the Markdown, then maybe the
macros
plugin can help you.https://www.mkdocs.org/user-guide/configuration/#extra
https://mkdocs-macros-plugin.readthedocs.io/en/latest/