Skip to content

Creating a website via config

It is possible to construct a basic documentation website without writing any Python code by describing the node tree in the config. The default build function (mkdocs_mknodes:parse) builds the nav from the pages setting.

The following config...

# pyproject.toml
[[tool.mknodes.pages]]
title = "Home"
type = "MkText"
text = "# mkdocs-mknodes (merged into mknodes)

This package has been merged into [mknodes](https://github.com/phil65/mknodes) (4.0+), which now
contains the site generator: `mknodes build` / `serve` / `generate`.

```bash
uv add --group docs "mknodes>=4.0.0"
uv run mknodes build

Settings stay in [tool.mknodes] of pyproject.toml. The default build function is now mknodes.site:parse (was mkdocs_mknodes:parse); custom build functions are unchanged.

Documentation: https://phil65.github.io/mknodes/

The history of this repository is part of the mknodes repository. " is_index = true

[[tool.mknodes.pages]] Usage = [ { title = "Getting started", type = "MkText", text = "Install the package and import it." }, { title = "Changelog", type = "MkChangelog" }, ]

[[tool.mknodes.pages]] title = "API" type = "MkDoc" section_name = "API" recursive = true

[[tool.mknodes.pages]] title = "CLI" type = "MkCliDoc" show_subcommands = true condition = "typer"

[[tool.mknodes.pages]] Development = [ { title = "Contributing", type = "MkCommitConventions" }, { title = "Dependencies", type = "MkDependencyTable" }, { title = "License", type = "MkLicense" }, ]

Combined with this CLI call...

``` {.terminal }
mkdocs-mknodes build

...creates a website with a home page, a usage section, API docs, a CLI page (if the project has a CLI) and a development section.

Page info
Code for this page
mkdocs_mknodes.manual.use_cases_section._
@nav.route.page("Creating a website via config", hide="toc")
def _(page: mk.MkPage):
    """Create the "Creating a website via config" MkPage."""
    config = (paths.RESOURCES / "pages_example.toml").read_text("utf-8")
    variables = {"config": config}
    page += mk.MkTemplate("use_case_default_website.jinja", variables=variables)
Resources
Resources(css=[],
          markdown_extensions={'pymdownx.highlight': {'anchor_linenums': True,
                                                      'line_spans': '__span',
                                                      'pygments_lang_class': True},
                               'pymdownx.superfences': {}},
          plugins=[],
          js=[],
          assets=[],
          packages=[])
Metadata
created:
  source_filename: /home/runner/work/mkdocs-mknodes/mkdocs-mknodes/.venv/lib/python3.13/site-packages/anyenv/async_run.py
  source_function: run_sync.<locals>.wrapper
  source_line_no: 52
hide:
- toc
title: Creating a website via config