Skip to content

Page meta attribute missing in include #7995

Answered by kamilkrzyskow
DevOpsJeremy asked this question in Q&A
Discussion options

You must be logged in to vote

Hello @DevOpsJeremy,
you need to remember that your Jinja template runs not only for your Pages (which are derived from Markdown files), but also for other static templates like the 404.html page (only this one by default), and these don't have any page.meta, hence the None error.

File "/usr/local/lib/python3.11/site-packages/material/templates/404.html", line 4, in top-level template code

So to handle such cases always do a safety guard if page.meta and page.meta.variable, which can be seen in the docs:

{% if page and page.meta and page.meta.robots %}

I think that if page is not necessary anymore after an MkDocs f…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@kamilkrzyskow
Comment options

Answer selected by kamilkrzyskow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #7994 on February 12, 2025 09:07.