Closed JulioV closed 3 years ago
Thanks for reporting! I'll look into it straight away.
Hmm, weird, works for me exactly as it should (see attached screenshot), Have you cloned Insiders from the master
or downloaded the *.tar.gz
package? Also, the line numbers (i.e. in nav-item.html
) are somehow off for all files I checked, e.g. material/base.html
only has 225 lines, so there's no line 360. If you didn't install from master
, could you try that?
You can also message me on Gitter.
Okay, so I looked at the templates again and maybe have a fix for what you're seeing, albeit I cannot test it, as I cannot reproduce it. The older parts of the templates used +
for string concatenation in Jinja templates for a long time, instead of ~
which should be used. The latter coerces all expressions to strings before concatenating, so as the error you're seeing says that there's a type mismatch for the +
operator, I replaced all string concatenations with ~
in 86a4c47c0aee5bb42b3d7435c05d24936c32e397 which I also just merged into the master
of Insiders.
Could you reinstall Insiders and try again?
pip install --force-reinstall git+https://${GH_TOKEN}@github.com/squidfunk/mkdocs-material-insiders.git
I originally downloaded the repo as a zip file, not sure why this mattered. However, it's working now after the last commits to master, thanks!
Perfect! I’ll investigate the zip file issue, but great that it works for you now!
Sorry to comment on an old issue, but I think that I identified the reason for that.
It seems that it is related to the Jinja2 version. mkdocs requires Jinja2>=2.10.3
on its requirements.txt, but when I defined Jinja2==2.11.3
in my project, it solved the issue.
Thanks! It might be worth raising this issue over at MkDocs, so they bump the Jinja version in their requirements, as Jinja is a transitive dependency for us. This would automatically install a new version when MkDocs is upgraded.
I have a similar problem on Ubuntu 20.04
The related software versions are:
mkdocs 1.2.1
mkdocs-enumerate-headings-plugin 0.4.5
mkdocs-git-authors-plugin 0.4.1
mkdocs-git-committers-plugin 0.2.2
mkdocs-git-revision-date-localized-plugin 0.9.2
mkdocs-git-revision-date-plugin 0.3.1
mkdocs-material 7.1.9
mkdocs-material-extensions 1.0.1
mkdocs-minify-plugin 0.4.0
mkdocs-plugin-progress 1.2.0
mkdocs-redirects 1.0.3
Jinja2 2.10.1
Distributor ID: Ubuntu
Description: Ubuntu 20.04 LTS
Release: 20.04
Codename: focal
When mkdocs build
, print the following error information
INFO - Processing page "101_memo/site_mind.md"...
INFO - Contextualized template 404.html.
Traceback (most recent call last):
File "/usr/local/bin/mkdocs", line 8, in <module>
sys.exit(cli())
File "/usr/lib/python3/dist-packages/click/core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "/usr/lib/python3/dist-packages/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/usr/lib/python3/dist-packages/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/lib/python3/dist-packages/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/lib/python3/dist-packages/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/mkdocs/__main__.py", line 183, in build_command
build.build(config.load_config(**kwargs), dirty=not clean)
File "/usr/local/lib/python3.8/dist-packages/mkdocs/commands/build.py", line 298, in build
_build_theme_template(template, env, files, config, nav)
File "/usr/local/lib/python3.8/dist-packages/mkdocs/commands/build.py", line 111, in _build_theme_template
output = _build_template(template_name, template, files, config, nav)
File "/usr/local/lib/python3.8/dist-packages/mkdocs/commands/build.py", line 90, in _build_template
output = template.render(context)
File "/usr/lib/python3/dist-packages/jinja2/asyncsupport.py", line 76, in render
return original_render(self, *args, **kwargs)
File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 1008, in render
return self.environment.handle_exception(exc_info, True)
File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/python3/dist-packages/jinja2/_compat.py", line 37, in reraise
raise value.with_traceback(tb)
File "/usr/local/lib/python3.8/dist-packages/material/404.html", line 4, in <module>
{% extends "main.html" %}
File "/usr/local/lib/python3.8/dist-packages/material/main.html", line 4, in <module>
{% extends "base.html" %}
File "/usr/local/lib/python3.8/dist-packages/material/base.html", line 128, in <module>
{% block site_nav %}
File "/usr/local/lib/python3.8/dist-packages/material/base.html", line 136, in <module>
{% include "partials/nav.html" %}
File "/usr/local/lib/python3.8/dist-packages/material/partials/nav.html", line 27, in <module>
{% include "partials/nav-item.html" %}
File "/usr/local/lib/python3.8/dist-packages/material/partials/nav-item.html", line 67, in <module>
{{ render(nav_item, path, level) }}
File "/usr/lib/python3/dist-packages/jinja2/runtime.py", line 583, in _invoke
rv = self._func(*arguments)
File "/usr/local/lib/python3.8/dist-packages/material/partials/nav-item.html", line 10, in <module>
{% if "navigation.sections" in features and level == 1 + (
TypeError: unsupported operand type(s) for +: 'int' and 'str'
After I upgrade Jinja to latest (3.0.1)
Jinja2 3.0.1
and then everything is ok, thanks very much!
For the Googlers, I ran into the same issue here: https://github.com/binwiederhier/ntfy/actions/runs/1550547757 and fixed it with an explicit jinja2 dependency, here: https://github.com/binwiederhier/ntfy/commit/ab3cc47e272aa0d21f8b3fd134265611916b6416#diff-4d7c51b1efe9043e44439a949dfd92e5827321b34082903477fd04876edb7552R4
Thanks @liuhualh for the hint and thanks @squidfunk for a freaking awesome piece of software (which has docs here: https://ntfy.sh/docs).
We added Jinja as an explicit dependency in https://github.com/squidfunk/mkdocs-material/commit/905c8b77c689e459b37b64564d81775d5ca60879, released as part of 7.3.3, see here:
I've found a bug and checked that ...
Description
I get the following error when activating section based navigation with
mkdocs-material-6.1.4+insiders-1.9.0
in a minimal website.Expected behavior
Load the website without errors and with section navigation
Actual behavior
The website is not rendered
Steps to reproduce the bug
mkdocs-material-6.1.4+insiders-1.9.0
/docs/test.md
with this line# My Test
Package versions
python --version
mkdocs --version
pip show mkdocs-material | grep -E ^Version
Project configuration
System information