pyssg is pre-1.0 and under active development - APIs, config, and themes may change.
pyssg.plugins.frontmatter

1 min read

pyssg.plugins.frontmatter

Frontmatter plugin.

Splits a leading YAML frontmatter block (delimited by --- lines) off the raw content, merges its keys into node.meta (the frontmatter aspect), and stores the remaining body under __body__ for the markdown parser. Runs in an early parse stage so the markdown plugin sees the stripped body.

Third-party (PyYAML) is confined to this peripheral plugin.

split_frontmatter(raw: str) -> tuple[dict[str, object], str]

Return (metadata, body); metadata is empty if there is no frontmatter.

class FrontmatterPlugin

Extracts YAML frontmatter into node.meta.

FrontmatterPlugin.apply(self, builder: Builder) -> None

frontmatter() -> FrontmatterPlugin

Factory used in pyssg.config.py.