Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jinja2.exceptions.UndefinedError: 'current_page' is undefined #266

Closed
ghost opened this issue Dec 3, 2014 · 14 comments
Closed

jinja2.exceptions.UndefinedError: 'current_page' is undefined #266

ghost opened this issue Dec 3, 2014 · 14 comments
Labels
Milestone

Comments

@ghost
Copy link

ghost commented Dec 3, 2014

I am using your mkdocs theme in my mkdcos project, and when i run this it shows following error:

jinja2.exceptions.UndefinedError: 'current_page' is undefined.

I think code for this is in toc.html file in mkdocs theme.

@d0ugal
Copy link
Member

d0ugal commented Dec 3, 2014

Interesting, this is odd. I can't see how this would happen.

Have you done anything to customise the theme? Are you using mkdocs 0.11.1?

@ianalexander
Copy link

I can also reproduce this with the following steps:

  • Copy the readthedocs theme into the root of the project directory
  • rename readthedocs to mytheme
  • add theme_dir: 'mytheme' to the yml config
  • run mkdocs build

The workaround is to delete the offending file (breadcrumbs.html) and use it in conjunction with theme: readthedocs in the yml file.

@ghost
Copy link
Author

ghost commented Dec 4, 2014

Yes I am using mkdocs 0.11.1 and I didn't done anything to customize the theme. I just copy the readthedocs theme to the root, set theme_dir: 'readthedocs' in yml config. and when I run it locally it gives the error of current_page is undefined.

@ghost
Copy link
Author

ghost commented Dec 4, 2014

Suggestion from Ianalexander is working, but i don't want to build it to static content. I want to publish it as python app.
Because when i build it every static html page contains whole customize footer code.

@manuelbua
Copy link

I experience the same problem, also switching theme, for example copying spacelab or cyborg will result in 'meta' is undefined errors. (version 0.11.1 here)

@manuelbua
Copy link

Uh! I found out a workaround: by forcing theme: "" as well as specifying the theme_dir parameter will work fine!

@d0ugal
Copy link
Member

d0ugal commented Dec 8, 2014

Interesting. This should be fixed by #244 then.

@manuelbua
Copy link

@d0ugal, yes this fixes this issue's problem and the other one where the build command copy all themes and everything (happens if theme: "" is specified as a workaround): i applied the fix for #244 and i could remove the workaround just fine, thanks!

@d0ugal d0ugal added the Bug label Dec 12, 2014
@d0ugal d0ugal added this to the 0.12.0 milestone Dec 12, 2014
@peter1000
Copy link
Contributor

jinja2.exceptions.UndefinedError: 'meta' is undefined

Copying themes bootstrap to project folder named: mybootstrap

only .yml entry

site_name: The website
theme_dir: 'mybootstrap'

ERROR

$ mkdocs serve
Traceback (most recent call last):
  File "/usr/bin/mkdocs", line 9, in <module>
    load_entry_point('mkdocs==0.11.1', 'console_scripts', 'mkdocs')()
  File "/usr/lib/python3.4/site-packages/mkdocs-0.11.1-py3.4.egg/mkdocs/main.py", line 74, in run_main
    main(cmd, args=sys.argv[2:], options=dict(opts))
  File "/usr/lib/python3.4/site-packages/mkdocs-0.11.1-py3.4.egg/mkdocs/main.py", line 46, in main
    serve(config, options=options)
  File "/usr/lib/python3.4/site-packages/mkdocs-0.11.1-py3.4.egg/mkdocs/serve.py", line 85, in serve
    build(config, live_server=True)
  File "/usr/lib/python3.4/site-packages/mkdocs-0.11.1-py3.4.egg/mkdocs/build.py", line 223, in build
    build_pages(config)
  File "/usr/lib/python3.4/site-packages/mkdocs-0.11.1-py3.4.egg/mkdocs/build.py", line 155, in build_pages
    build_404(config, env, site_navigation)
  File "/usr/lib/python3.4/site-packages/mkdocs-0.11.1-py3.4.egg/mkdocs/build.py", line 142, in build_404
    output_content = template.render(global_context)
  File "/usr/lib/python3.4/site-packages/jinja2/environment.py", line 969, in render
    return self.environment.handle_exception(exc_info, True)
  File "/usr/lib/python3.4/site-packages/jinja2/environment.py", line 742, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/python3.4/site-packages/jinja2/_compat.py", line 36, in reraise
    raise value.with_traceback(tb)
  File "/usr/lib/python3.4/site-packages/mkdocs-0.11.1-py3.4.egg/mkdocs/themes/mkdocs/404.html", line 1, in <module>
    {% extends "base.html" %}
  File "mybootstrap/base.html", line 48, in <module>
    <div class="col-md-9" role="main">{% include "content.html" %}</div>
  File "mybootstrap/content.html", line 1, in <module>
    {% if meta.source %}
  File "/usr/lib/python3.4/site-packages/jinja2/environment.py", line 397, in getattr
    return getattr(obj, attribute)
jinja2.exceptions.UndefinedError: 'meta' is undefined

Patch: #244 seems not to help for this case

@d0ugal
Copy link
Member

d0ugal commented Mar 17, 2015

@peter1000 Can you report that as a new issue? Seems to be a different problem.

@peter1000
Copy link
Contributor

Done

@d0ugal
Copy link
Member

d0ugal commented Apr 2, 2015

I believe this is now fixed in the latest master, please let me know if it isn't.

@d0ugal d0ugal closed this as completed Apr 2, 2015
@gsouf
Copy link

gsouf commented Mar 26, 2016

Getting the issue with 0.15.3 (the one I grabbed from pip) and @manuelbua workarround (theme: "") does not work:

INFO    -  Building documentation... 
ERROR   -  Config value: 'theme'. Error: Unrecognised theme ''. The available installed themesare:  

Aborted with 1 Configuration Errors!

@waylan
Copy link
Member

waylan commented Mar 27, 2016

@gsouf I would suggest you open a new issue. The related code is completely different today than when this issue was opened. The discussion here is no longer relevant in any way. In your new issue, be sure to include the minimal steps to reproduce the error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants