mkdocs build crashes when navigation.sections is enabled.
See original GitHub issue- [ X ] I’ve read the contribution guidelines and agree with them
I’ve found a bug and checked that …
- [ X ] … the problem doesn’t occur with the default MkDocs template
- [ X ] … the problem is not in any of my customizations (CSS, JS, template)
- [ X ] … the documentation does not mention anything about my problem
- [ X ] … there are no open or closed issues that are related to my problem
Description
mkdocs build crashes when navigation.sections is enabled.
Expected behavior
was hoping to see the behavior described in the documentation.
Actual behavior
barfs as described below.
Steps to reproduce the bug
mkdoc-material bug
root@annie:/home/don# lxc launch ubuntu/focal/cloud mkdocs -p susdev21 -p default
Creating mkdocs
Starting mkdocs
root@annie:/home/don# lxc exec mkdocs bash
root@mkdocs:~# apt-get update
...
root@mkdocs:~# apt-get install nano git wget python3-pip
...
root@mkdocs:/var/www# pip3 install mkdocs-material
...
root@mkdocs:~# mkdir /var/www/
root@mkdocs:~# cd /var/www
root@mkdocs:/var/www# git clone https://github.com/feurig/digithink.git
Cloning into 'digithink'...
...
root@mkdocs:/var/www# cd digithink/
root@mkdocs:/var/www/digithink# nano mkdocs.yml
site_name: works4me
theme:
name: material
features:
- navigation.expand
root@mkdocs:/var/www/digithink# mkdocs build
INFO - Cleaning site directory
INFO - Building documentation to directory: /var/www/digithink/site
INFO - Documentation built in 1.90 seconds
root@mkdocs:/var/www/digithink# nano mkdocs.yml
site_name: buggy
theme:
name: material
features:
- navigation.sections
root@mkdocs:/var/www/digithink# mkdocs build
INFO - Cleaning site directory
INFO - Building documentation to directory: /var/www/digithink/site
Traceback (most recent call last):
File "/usr/local/bin/mkdocs", line 8, in <module>
sys.exit(cli())
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/mkdocs/__main__.py", line 152, 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 285, in build
_build_theme_template(template, env, files, config, nav)
File "/usr/local/lib/python3.8/dist-packages/mkdocs/commands/build.py", line 108, 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 87, 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 129, in <module>
{% block site_nav %}
File "/usr/local/lib/python3.8/dist-packages/material/base.html", line 137, in <module>
{% include "partials/nav.html" %}
File "/usr/local/lib/python3.8/dist-packages/material/partials/nav.html", line 31, in <module>
{% include "partials/nav-item.html" %}
File "/usr/local/lib/python3.8/dist-packages/material/partials/nav-item.html", line 71, in <module>
{{ render_nav_item(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'
Package versions
Python: python --version
root@mkdocs:/var/www/digithink# python3 --version Python 3.8.5
MkDocs: mkdocs --version
root@mkdocs:/var/www/digithink# mkdocs --version mkdocs, version 1.1.2 from /usr/local/lib/python3.8/dist-packages/mkdocs (Python 3.8)
Material: pip show mkdocs-material | grep -E ^Version
root@mkdocs:/var/www/digithink# pip3 show mkdocs-material | grep -E ^Version Version: 6.2.8
Project configuration
#The contents of your mkdocs.yml
# as described above....
site_name: buggy
theme:
name: material
features:
- navigation.sections
System information
-
OS: Ubuntu 20.04
-
Browser: Not Relevent
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Release Notes - MkDocs
Internal handling of pages, files and navigation has been completely refactored. The changes included in the refactor are summarized below.
Read more >Changelog - Material for MkDocs - GitHub Pages
Fixed #4348: Blog plugin crashes on custom nav title; Fixed blog plugin crashing when category contained only drafts; Fixed rendering of content from...
Read more >How to create beautiful documentation? | Material for mkdocs
In this tutorial, we will learn to create beautiful documentation of your awesome Github projects.source code final: ...
Read more >How to Create & Publish Documentations For Your Packages
Material for mkdocs | Crash Course | #c17hawke ... Sphinx - How to generate documentation from python doc strings - Five + Minutes...
Read more >Deploying a MkDocs documentation site with GitHub Actions
Once the build workflow is complete, the pages-build-deployment workflow takes over and deploys the changes to Pages. A common practice when ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you @whiskeysierra You saved my day 😉 I can confirm adding
Jinja2>=2.11.1
in requirements.txt +pip install -r requirements.txt
saves a lot of headaches.Thats cool. I will come back to this when I have more time. I opened the issue because you asked me to. I am happy without using the extension.sections and am fine with closing this out.
D.
FWIW when I run mkdocs against itself I get a different error.