Skip to content

Jinja2 errors after upgrading to 9.6.10 with pip #8133

@johnnovak

Description

@johnnovak

Context

Update: Upgrading to the latest Jinja2 3.1.6 manually resolved the issue. I was on 3.0.3 and upgrading to the latest mkdocs material version did not cause Jinja2 to upgrade.

Someone apparently is trying to fix it here:
#8132

Bug description

I'm a long-time mkdocs material users. I've done a pip install mkdocs-material this morning to upgrade, which went fine, but I'm no longer able to use it as it keeps failing with a Jinja 2 error.

I've uninstalled then reinstalled mkdocs-material, but it didn't help.

mkdocs itself works; it's apparently the templates in mkdocs material that isn't compatible with a more recent version of jinja2 or something.

This is the error I'm getting:

INFO - Building documentation... INFO - Cleaning site directory Traceback (most recent call last): File "/home/jnovak/.local/bin/mkdocs", line 8, in <module> sys.exit(cli()) File "/home/jnovak/.local/lib/python3.10/site-packages/click/core.py", line 1157, in __call__ return self.main(*args, **kwargs) File "/home/jnovak/.local/lib/python3.10/site-packages/click/core.py", line 1078, in main rv = self.invoke(ctx) File "/home/jnovak/.local/lib/python3.10/site-packages/click/core.py", line 1688, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/home/jnovak/.local/lib/python3.10/site-packages/click/core.py", line 1434, in invoke return ctx.invoke(self.callback, **ctx.params) File "/home/jnovak/.local/lib/python3.10/site-packages/click/core.py", line 783, in invoke return __callback(*args, **kwargs) File "/home/jnovak/.local/lib/python3.10/site-packages/mkdocs/__main__.py", line 272, in serve_command serve.serve(**kwargs) File "/home/jnovak/.local/lib/python3.10/site-packages/mkdocs/commands/serve.py", line 85, in serve builder(config) File "/home/jnovak/.local/lib/python3.10/site-packages/mkdocs/commands/serve.py", line 67, in builder build(config, serve_url=None if is_clean else serve_url, dirty=is_dirty) File "/home/jnovak/.local/lib/python3.10/site-packages/mkdocs/commands/build.py", line 328, in build _build_theme_template(template, env, files, config, nav) File "/home/jnovak/.local/lib/python3.10/site-packages/mkdocs/commands/build.py", line 103, in _build_theme_template output = _build_template(template_name, template, files, config, nav) File "/home/jnovak/.local/lib/python3.10/site-packages/mkdocs/commands/build.py", line 83, in _build_template output = template.render(context) File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 1291, in render self.environment.handle_exception() File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 925, in handle_exception raise rewrite_traceback_stack(source=source) File "/home/jnovak/.local/lib/python3.10/site-packages/material/templates/404.html", line 4, in top-level template code {% extends "main.html" %} File "/home/jnovak/.local/lib/python3.10/site-packages/material/templates/main.html", line 4, in top-level template code {% extends "base.html" %} File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 925, in handle_exception raise rewrite_traceback_stack(source=source) File "/home/jnovak/.local/lib/python3.10/site-packages/material/templates/base.html", line 80, in template <meta {% for key, value in tag | items %} {{ key }}="{{value}}" {% endfor %}> jinja2.exceptions.TemplateAssertionError: No filter named 'items'. 

Related links

N/A

Reproduction

Skipping this step as the problem is reproducible with the minimal website from the tutorial.

Steps to reproduce

  1. Create a new mkdocs site with mkdocs new
  2. Set up a basic mkdocs material site (from the tutorial):
site_name: My Docs site_url: https://mydomain.org/mysite theme: name: material
  1. Execute either mkdocs server or mkdocs build.

Browser

Firefox

Before submitting

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue reports a bugresolvedIssue is resolved, yet unreleased if open

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions