page.meta["template"] throws error on mkdocs serve
since updating to 9.6.1. Why?
#7948
-
Since I updated to 9.6.1 of mkdocs-material am I encountering the following error whenever I try to Error
This error points to a hook I created, which simply listens for from mkdocs.structure.pages import Page
def on_page_markdown(markdown: str, /, *, page: Page, config, files) -> str | None:
if page.meta["template"] != "blog-post.html":
return
return f"{markdown}\n\nMore Lorem Ipsum" What is interesting, is that this error won't show, if I add the if-condition while serve is already running (So it only updates)... Tho, I cannot reproduce that behaviour on reproduction unfortunately. The hook was working fine before updating mkdocs-material, so something must've changed that makes this no longer work reliably. I've not made this an issue, as I'm unsure on whether this truly is an issue in mkdocs-material, or a bad coding design on my end... |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey @Andre601,
Adding Python code after running mkdocs serve won't reload the Python code. You need to completely shut it down, and run mkdocs serve again. |
Beta Was this translation helpful? Give feedback.
Hey @Andre601,
the value comes from MkDocs, if you updated the theme then it might've updated the MkDocs base.
meta
should always be a dict-like structure so replace it withpage.meta.get("template")
to not crash.Adding Python code after running mkdocs serve won't reload the Python code. You need to completely shut it down, and run mkdocs serve again.