Mkdocs-material: Error when using a different language in version 5

Created on 7 Apr 2020  ยท  3Comments  ยท  Source: squidfunk/mkdocs-material

__I checked that...__

  • [x] ... the documentation does not mention anything about my problem
  • [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] ... there are no open or closed issues that are related to my problem

Description

After upgrading mkdocs-material to version 5, when using a specific language (e.g. es) it can't build the site.

Expected behavior

To build the site in the specified language (if it's one of the supported languages).

Actual behavior

An error is thrown.

Steps to reproduce the bug

  • Create a new directory, e.g. material5.
  • Create a new Python environment for it (e.g. with Poetry)
  • Install mkdocs-material in it (it gets the latest version, 5)
  • Create a directory docs.
  • Create an empty file ./docs/tutorial.md.
  • Create a mkdocs.yml file with:
site_name: MkLorum
theme:
  name: material
  language: es

So, the directory tree looks something like:

.
โ”œโ”€โ”€ docs
โ”‚ย ย  โ””โ”€โ”€ tutorial.md
โ”œโ”€โ”€ mkdocs.yml
โ”œโ”€โ”€ poetry.lock
โ””โ”€โ”€ pyproject.toml

Then serve with mkdocs:

$ mkdocs serve

...

  File "/home/user/.cache/pypoetry/virtualenvs/material5-JlbqKcKF-py3.6/lib/python3.6/site-packages/jinja2/_compat.py", line 28, in reraise
    raise value.with_traceback(tb)
  File "/home/user/.cache/pypoetry/virtualenvs/material5-JlbqKcKF-py3.6/lib/python3.6/site-packages/material/partials/language/es.html", line 16, in template
    "search.config.lang": "es",
jinja2.exceptions.TemplateSyntaxError: expected token ',', got ':'

An error is thrown :cry:

But removing the language: es, so that mkdocs.yml is like:

site_name: MkLorum
theme:
  name: material

Fixes the error:

$ mkdocs serve

INFO    -  Building documentation...
INFO    -  Cleaning site directory
INFO    -  Documentation built in 0.13 seconds
[I 200407 21:03:39 server:296] Serving on http://127.0.0.1:8000
INFO    -  Serving on http://127.0.0.1:8000
[I 200407 21:03:39 handlers:62] Start watching changes
INFO    -  Start watching changes
[I 200407 21:03:39 handlers:64] Start detecting changes
INFO    -  Start detecting changes

Package versions

  • Python: python --version: Python 3.6.9 :: Anaconda custom (64-bit)
  • MkDocs: mkdocs --version: mkdocs, version 1.1
  • Material: pip show mkdocs-material | grep -E ^Version: Version: 5.0.0

Project configuration

site_name: MkLorum
theme:
  name: material
  language: es

System information

  • OS: Ubuntu 18.04
  • Browser: Chrome
bug

All 3 comments

Confirmed! It's actually a syntax error in the template. Fixed in 184dfea0, will issue 5.0.1 straight away.

5.0.1 was just released. Thanks for reporting!

Wow, that was fast! Thanks a lot!

And I didn't say before, thanks for this awesome theme! I'm using it everywhere :smile:
(https://fastapi.tiangolo.com/ and https://typer.tiangolo.com/)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

danierutu picture danierutu  ยท  3Comments

HerbFargus picture HerbFargus  ยท  4Comments

oliverschwendener picture oliverschwendener  ยท  4Comments

ngtrian picture ngtrian  ยท  3Comments

madrus picture madrus  ยท  3Comments