Replies: 2 comments 6 replies
-
Thanks for your question. I am not sure exactly what issue you are meeting. Perhaps a formatting issue in the plugins:
- search
- macros
include_yaml:
- assets/data/extra_tabs_data.yml The last line looks suspicious to me, because there should be an indentation. Since I do not see why there should be an |
Beta Was this translation helpful? Give feedback.
-
Now that you mention it, we could do something bold for a future development: we could automatically trickle part or all the variables into the MkDocs engine. 🤔 💡 . Technically, it would be fairly easy to do. The main question would be to make sure that there are no bad side effects. |
Beta Was this translation helpful? Give feedback.
-
Just started using MkDocs and discovered this plugin, awesome!
Use case
I use Material for MkDocs and want to add extra menu items(e.g. an extra Download Now link).
What works but suboptimal
What I did to make it work:
Added a variable to extra in mkdocs.yml:
Override tabs.html partial and add some code to generate the menu items:
What I need
I now want to use the macros plugin and use
include_yaml
to split data from configuration. What I thought would work:Add the macros plugin and configure it to include an external yaml file and remove the extra_tabs variable under extra in mkdocs.yml
Created a file extra_tabs_data.yml containing the data needed:
In the tabs.html partial, access the
extra_tabs
variable to generate the menu itemsHowever this did not work, nothing was rendered.
What I tried
In the tabs.html partial, I used
extra_tabs
,config.extra.extra_tabs
and some other combinations as variable and removed the if clause.I used a key: value pair to include the yaml file using
et: assets/data/extra_tabs_data.yml
. During serving, an error was thrown:jinja2.exceptions.UndefinedError: 'mkdocs.config.defaults.MkDocsConfig object' has no attribute 'et'
Questions
I thought I would be able to use the
extra
as stated in use include_yaml macro to add the nav section does not work #181Beta Was this translation helpful? Give feedback.
All reactions