{"record":{"id":"faef459d28d76736","repo":"squidfunk/mkdocs-material","slug":"error-reading-metadata-of-post-path-in-docs-faef45","errorCode":null,"errorMessage":"Error reading metadata of post '{path}' in '{docs}':\n{e}","messagePattern":"Error reading metadata of post '(.+?)' in '(.+?)':\n(.+?)","errorType":"exception","errorClass":"PluginError","httpStatus":null,"severity":"error","filePath":"src/plugins/blog/structure/__init__.py","lineNumber":86,"sourceCode":"            # correctly implemented anyway. When using MultiMarkdown syntax, all\n            # date formats are returned as strings and list are not properly\n            # supported. Thus, we just use the relevants parts of `get_data`.\n            match: Match = YAML_RE.match(self.markdown)\n            if not match:\n                raise PluginError(\n                    f\"Error reading metadata of post '{path}' in '{docs}':\\n\"\n                    f\"Expected metadata to be defined but found nothing\"\n                )\n\n            # Extract metadata and parse as YAML\n            try:\n                self.meta = yaml.load(match.group(1), SafeLoader) or {}\n                self.markdown = self.markdown[match.end():].lstrip(\"\\n\")\n\n            # The post's metadata could not be parsed because of a syntax error,\n            # which we display to the author with a nice error message\n            except Exception as e:\n                raise PluginError(\n                    f\"Error reading metadata of post '{path}' in '{docs}':\\n\"\n                    f\"{e}\"\n                )\n\n            # Hack: if the meta plugin is registered, we need to move the call\n            # to `on_page_markdown` here, because we need to merge the metadata\n            # of the post with the metadata of any meta files prior to creating\n            # the post configuration. To our current knowledge, it's the only\n            # way to allow posts to receive metadata from meta files, because\n            # posts must be loaded prior to constructing the navigation in\n            # `on_files` but the meta plugin first runs in `on_page_markdown`.\n            plugin: MetaPlugin = config.plugins.get(\"material/meta\")\n            if plugin:\n                plugin.on_page_markdown(\n                    self.markdown, page = self, config = config, files = None\n                )\n\n        # Initialize post configuration, but remove all keys that this plugin","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/squidfunk/mkdocs-material/blob/e2136532f40aed98af1f6497c0cc6a3cff9f759b/src/plugins/blog/structure/__init__.py#L68-L104","documentation":"After extracting the post's YAML front-matter, the plugin parses it with `yaml.load(..., SafeLoader)`. If parsing fails for any reason (invalid YAML syntax, wrong types, tabs, duplicate keys, etc.), the caught exception is re-raised as this PluginError with the original yaml message appended, pointing the author to the offending post.","triggerScenarios":"A post's front-matter contains invalid YAML: unquoted colons in values, tabs for indentation, unclosed brackets/quotes, an invalid date value, or any construct the SafeLoader rejects.","commonSituations":"Hand-editing front-matter and breaking indentation; pasting values with special characters like `:` or `#` unquoted; YAML 1.1 syntax not accepted by the safe loader; malformed dates like `date: 31.12.2024`.","solutions":["Read the appended yaml error message and fix the syntax at the indicated line in the post's front-matter","Quote string values containing special characters (`title: \"My: Post\"`)","Replace tabs with spaces and ensure consistent indentation","Validate dates use ISO format, e.g. `date: 2024-01-15`"],"exampleFix":"# before\n---\ntitle: My: Post\ndate: 31.12.2024\n---\n\n// after\n---\ntitle: \"My: Post\"\ndate: 2024-12-31\n---","handlingStrategy":"validation","validationCode":"import yaml\nfrom pathlib import Path\nfor p in Path('docs/posts').rglob('*.md'):\n    text = p.read_text(encoding='utf-8-sig')\n    if text.startswith('---'):\n        block = text.split('---')[1]\n        yaml.safe_load(block)  # raises with line info if invalid\n","typeGuard":null,"tryCatchPattern":"try:\n    mkdocs.commands.build(config)\nexcept PluginError as e:\n    if \"Error reading metadata of post\" in str(e):\n        log.error(f\"Fix YAML syntax in post front matter: {e}\")\n    raise\n","preventionTips":["Validate all post front-matter with a YAML linter before committing","Quote strings containing colons or special characters","Use spaces, never tabs, in front-matter","Use ISO 8601 dates in metadata"],"tags":["mkdocs","blog-plugin","yaml","front-matter","syntax-error"],"backgroundTag":"yaml-parse-error","analyzedSha":"e2136532f40aed98af1f6497c0cc6a3cff9f759b","analyzedAt":"2026-08-29T11:20:04.299Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}