You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm migrating my docs repo. And was tried to use mkdocs with material theme to build blog somewhat. I use obsidian as the editor. And the default metadata's tags will be empty. Also that I level it empty in most files.
Which looks like:
But as I enabled the tags plugin, empty tags section will be considered as a exception.
Bug description
The error messages and traceback:
ERROR - Error building page 'Arc/Game/ECS_With_UI.md': 'NoneType' object is not iterable
Traceback (most recent call last):
File "C:\Users\norm\miniconda3\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\norm\miniconda3\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "C:\Users\norm\miniconda3\Scripts\mkdocs.exe_main.py", line 7, in
File "C:\Users\norm\miniconda3\lib\site-packages\click\core.py", line 1157, in call
return self.main(*args, **kwargs)
File "C:\Users\norm\miniconda3\lib\site-packages\click\core.py", line 1078, in main
rv = self.invoke(ctx)
File "C:\Users\norm\miniconda3\lib\site-packages\click\core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "C:\Users\norm\miniconda3\lib\site-packages\click\core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Users\norm\miniconda3\lib\site-packages\click\core.py", line 783, in invoke
return _callback(*args, **kwargs)
File "C:\Users\norm\miniconda3\lib\site-packages\mkdocs_main.py", line 270, in serve_command
serve.serve(**kwargs)
File "C:\Users\norm\miniconda3\lib\site-packages\mkdocs\commands\serve.py", line 86, in serve
builder(config)
File "C:\Users\norm\miniconda3\lib\site-packages\mkdocs\commands\serve.py", line 67, in builder
build(config, live_server=None if is_clean else server, dirty=is_dirty)
File "C:\Users\norm\miniconda3\lib\site-packages\mkdocs\commands\build.py", line 349, in build
_build_page(
File "C:\Users\norm\miniconda3\lib\site-packages\mkdocs\commands\build.py", line 222, in _build_page
context = config.plugins.on_page_context(context, page=page, config=config, nav=nav)
File "C:\Users\norm\miniconda3\lib\site-packages\mkdocs\plugins.py", line 583, in on_page_context
return self.run_event('page_context', context, page=page, config=config, nav=nav)
File "C:\Users\norm\miniconda3\lib\site-packages\mkdocs\plugins.py", line 507, in run_event
result = method(item, **kwargs)
File "C:\Users\norm\miniconda3\lib\site-packages\material\plugins\tags\plugin.py", line 117, in on_page_context
context["tags"] = [
TypeError: 'NoneType' object is not iterable
Hello! I noticed that many of my notes currently have empty tags in the metadata section. Are these empty tags considered valid for mkdocs?
I just encountered an exception in the source code related to this when I execute build/serve process to create a blog. And the exception which I've already addressed by making modifications and testing them thoroughly.
Everything seems to be working smoothly now (just made a simple test)🎉🎉! Or are there any spec considerations I might have overlooked?
I have just gone ahead and created a pull request for this issue: #7098.
Thanks for reporting and creating the PR! I've ran your reproduction, and can't observe the problem. However, looking at the code, your proposed changes definitely make sense to better safe guard against such errors, and I can't rule out that it might be related to some other version of some other package that is causing the problem.
squidfunk
changed the title
tags plugin | Exception when zero tags in tags section of markdown's meta data when tags plugin enabled.
Tags plugin: sometimes crashes on empty tags
Apr 25, 2024
Context
I'm migrating my docs repo. And was tried to use mkdocs with material theme to build blog somewhat. I use
obsidian
as the editor. And the default metadata's tags will be empty. Also that I level it empty in most files.Which looks like:
Author: "@godot42"
Date: "{{date}} {{time}}"
pub: false
pub-category:
tags:
But as I enabled the tags plugin, empty tags section will be considered as a exception.
Bug description
The error messages and traceback:
ERROR - Error building page 'Arc/Game/ECS_With_UI.md': 'NoneType' object is not iterable
Traceback (most recent call last):
File "C:\Users\norm\miniconda3\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\norm\miniconda3\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "C:\Users\norm\miniconda3\Scripts\mkdocs.exe_main.py", line 7, in
File "C:\Users\norm\miniconda3\lib\site-packages\click\core.py", line 1157, in call
return self.main(*args, **kwargs)
File "C:\Users\norm\miniconda3\lib\site-packages\click\core.py", line 1078, in main
rv = self.invoke(ctx)
File "C:\Users\norm\miniconda3\lib\site-packages\click\core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "C:\Users\norm\miniconda3\lib\site-packages\click\core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Users\norm\miniconda3\lib\site-packages\click\core.py", line 783, in invoke
return _callback(*args, **kwargs)
File "C:\Users\norm\miniconda3\lib\site-packages\mkdocs_main.py", line 270, in serve_command
serve.serve(**kwargs)
File "C:\Users\norm\miniconda3\lib\site-packages\mkdocs\commands\serve.py", line 86, in serve
builder(config)
File "C:\Users\norm\miniconda3\lib\site-packages\mkdocs\commands\serve.py", line 67, in builder
build(config, live_server=None if is_clean else server, dirty=is_dirty)
File "C:\Users\norm\miniconda3\lib\site-packages\mkdocs\commands\build.py", line 349, in build
_build_page(
File "C:\Users\norm\miniconda3\lib\site-packages\mkdocs\commands\build.py", line 222, in _build_page
context = config.plugins.on_page_context(context, page=page, config=config, nav=nav)
File "C:\Users\norm\miniconda3\lib\site-packages\mkdocs\plugins.py", line 583, in on_page_context
return self.run_event('page_context', context, page=page, config=config, nav=nav)
File "C:\Users\norm\miniconda3\lib\site-packages\mkdocs\plugins.py", line 507, in run_event
result = method(item, **kwargs)
File "C:\Users\norm\miniconda3\lib\site-packages\material\plugins\tags\plugin.py", line 117, in on_page_context
context["tags"] = [
TypeError: 'NoneType' object is not iterable
Related links
Reproduction
9.5.18-tags_plugins_exception.zip
Steps to reproduce
Run mkdocs when tags of metadata is empty
Browser
No response
Before submitting
The text was updated successfully, but these errors were encountered: