Mkdocs-material: jinja2.exceptions.TemplateNotFound: .icons/.svg

Created on 14 Apr 2020  路  4Comments  路  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

Since the v5 release, I have a bug when deploying using Github action.

Expected behavior

Mkdocs to build then deploy on github pages.

Actual behavior

  File "/opt/hostedtoolcache/Python/3.8.2/x64/lib/python3.8/site-packages/mkdocs/commands/build.py", line 288, in build
    _build_theme_template(template, env, files, config, nav)
  File "/opt/hostedtoolcache/Python/3.8.2/x64/lib/python3.8/site-packages/mkdocs/commands/build.py", line 114, in _build_theme_template
    output = _build_template(template_name, template, files, config, nav)
  File "/opt/hostedtoolcache/Python/3.8.2/x64/lib/python3.8/site-packages/mkdocs/commands/build.py", line 93, in _build_template
    output = template.render(context)
  File "/opt/hostedtoolcache/Python/3.8.2/x64/lib/python3.8/site-packages/jinja2/environment.py", line 1090, in render
    self.environment.handle_exception()
  File "/opt/hostedtoolcache/Python/3.8.2/x64/lib/python3.8/site-packages/jinja2/environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "/opt/hostedtoolcache/Python/3.8.2/x64/lib/python3.8/site-packages/jinja2/_compat.py", line 28, in reraise
    raise value.with_traceback(tb)
  File "/opt/hostedtoolcache/Python/3.8.2/x64/lib/python3.8/site-packages/material/404.html", line 4, in top-level template code
    {% extends "base.html" %}
  File "/opt/hostedtoolcache/Python/3.8.2/x64/lib/python3.8/site-packages/material/base.html", line 176, in top-level template code
    {% block footer %}
  File "/opt/hostedtoolcache/Python/3.8.2/x64/lib/python3.8/site-packages/material/base.html", line 177, in block "footer"
    {% include "partials/footer.html" %}
  File "/opt/hostedtoolcache/Python/3.8.2/x64/lib/python3.8/site-packages/material/partials/footer.html", line 55, in top-level template code
    {% include "partials/social.html" %}
  File "/opt/hostedtoolcache/Python/3.8.2/x64/lib/python3.8/site-packages/material/partials/social.html", line 10, in top-level template code
    {% include ".icons/" ~ social.icon ~ ".svg" %}
  File "/opt/hostedtoolcache/Python/3.8.2/x64/lib/python3.8/site-packages/jinja2/loaders.py", line 197, in get_source
    raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: .icons/.svg

Steps to reproduce the bug

  1. mkdocs gh-deploy --force

Package versions

  • Python: python --version 3.8.2
  • MkDocs: mkdocs --version 1.1
  • Material: pip show mkdocs-material | grep -E ^Version latest (it still works with 4.4.3)

Project configuration

site_name: PhoneInfoga
repo_name: 'sundowndev/PhoneInfoga'
repo_url: 'https://github.com/sundowndev/PhoneInfoga'
site_description: 'Advanced information gathering & OSINT tool for phone numbers.'
site_author: 'Sundowndev'
copyright: 'PhoneInfoga was developed by sundowndev and is licensed under GPL-3.0.'
nav:
  - 'Welcome': index.md
  - 'Installation': install.md
  - 'Getting started': usage.md
  - 'Formatting phone numbers': formatting.md
  - 'Go module usage': go-module-usage.md
  - 'Resources': resources.md
  - 'Contribute': contribute.md
theme:
  name: material
  logo: 'images/logo_white.svg'
  favicon: 'images/logo.svg'
  palette:
    primary: 'blue grey'
    accent: 'brown'
extra:
  social:
    - type: 'github'
      link: 'https://github.com/sundowndev/PhoneInfoga'
    - type: 'twitter'
      link: 'https://twitter.com/sundowndev'

# Extensions
markdown_extensions:
  - markdown.extensions.admonition
plugins:
  - search
  - minify:
      minify_html: true

https://github.com/sundowndev/PhoneInfoga/blob/master/mkdocs.yml

System information

  • OS: ...
  • Browser: ...

Github action: https://github.com/sundowndev/PhoneInfoga/blob/master/.github/workflows/deploy-docs.yml

Most helpful comment

@sundowndev I had the problem you faced after updating the theme subitems to v5 schema. The solution was to update extra - social.

From (v4):

extra:
  social:
    - type: 'github'
      link: 'https://github.com/sundowndev/PhoneInfoga'

To (v5):

extra:
  social:
    - icon: fontawesome/brands/github-alt
      link: 'https://github.com/sundowndev/PhoneInfoga'

Replace type to icon. Hope to help someone getting into this trouble.

All 4 comments

Please read the migration guide. You need to adjust mkdocs.yml, as the config format changed.

@squidfunk Documentation isn't clear enough for me. Custom logo isn't supported anymore?

Turned this (v4)

theme:
  name: material
  logo: 'images/logo_white.svg'

into (v5):

  icon:
    logo: 'images/logo_white.svg'

But I'm still getting error jinja2.exceptions.TemplateNotFound: .icons/images/logo_white.svg.svg.

EDIT: Aight got it, I simply didn't have to edit logo field.

@sundowndev I had the problem you faced after updating the theme subitems to v5 schema. The solution was to update extra - social.

From (v4):

extra:
  social:
    - type: 'github'
      link: 'https://github.com/sundowndev/PhoneInfoga'

To (v5):

extra:
  social:
    - icon: fontawesome/brands/github-alt
      link: 'https://github.com/sundowndev/PhoneInfoga'

Replace type to icon. Hope to help someone getting into this trouble.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tiangolo picture tiangolo  路  3Comments

nikramakrishnan picture nikramakrishnan  路  3Comments

ngtrian picture ngtrian  路  3Comments

bborysenko picture bborysenko  路  4Comments

yannduran picture yannduran  路  4Comments