Skip to main content

mkdocs2notion

A command-line tool that converts a directory of Markdown documents—optionally structured with mkdocs.yml—into a fully-organized Notion workspace.

This utility mirrors the publishing behavior of MkDocs, but targets Notion pages instead of a static site.

All parsing and conversion logic is implemented natively in this repository, with an adapter layer that can use Ultimate Notion (if installed) or a future Notion SDK integration.


Features

  • 🗂 Publish entire Markdown folders to Notion
  • 📄 Accurate Markdown → Notion block conversion
  • 📚 Optional mkdocs.yml navigation support
  • 🔗 Maintains hierarchical structure and ordering
  • 🆔 Local file-path ↔ page-ID mapping for updates
  • 🛠 Dry-run mode for testing without touching Notion
  • ⚙️ Adapter layer to support different Notion clients
  • ☑️ Markdown task lists render as Notion to-dos

Why This Exists

Markdown is easy to write. Notion is easy to share/control.

But getting a structured Markdown knowledge base into Notion—and keeping it updated—is hard.

mkdocs2notion solves that by:

  • replicating MkDocs’ handling of directories, files, and nav trees,
  • converting Markdown into rich Notion blocks,
  • creating/updating pages while maintaining structure,
  • allowing teams to turn entire docs folders into Notion workspaces.

Installation

mkdocs2notion v0.2.0 is published on PyPI and GitHub.

Install from PyPI:

pip install mkdocs2notion

Or install the latest from GitHub:

pip install git+https://github.com/mahbam42/mkdocs2notion

Basic Usage

Push a directory to Notion

mkdocs2notion push docs/

With mkdocs.yml navigation

mkdocs2notion push docs/ --mkdocs mkdocs.yml

Dry run (see what would happen)

mkdocs2notion dry-run docs/

Validate docs without publishing

mkdocs2notion validate docs/ --mkdocs mkdocs.yml

CLI options

  • --mkdocs <path>: Use mkdocs.yml navigation ordering without requiring MkDocs to be installed.
  • --parent <page_id>: Override NOTION_PARENT_PAGE_ID for where new pages should live.
  • --fresh: Ignore the cached page-ID map and rebuild it before pushing.
  • --strict: Treat warnings as errors (push/dry-run/validate exit with status 1 when warnings are present).

Configuration

Environment variables

You will need a Notion API token:

NOTION_TOKEN=your-secret-token

Optional:

NOTION_PARENT_PAGE_ID=...   # where new pages should be created

How It Works

mkdocs2notion processes content in stages:

1. Directory Loader

  • Walks the directory
  • Reads Markdown files
  • Extracts titles (frontmatter or H1)
  • Generates metadata for each page

2. mkdocs.yml Navigation Loader (optional)

  • Reads mkdocs.yml
  • Builds an ordered tree of sections/pages

3. Markdown Parser

  • Converts Markdown into internal block structures
  • Converts those blocks into Notion-ready representations

4. Notion Adapter

A thin abstraction around Notion operations (via Ultimate Notion or another SDK):

  • create/update pages
  • send block updates
  • maintain parent-child relationships

You can swap the adapter without touching the logic.


Project Structure

mkdocs2notion/
│
├── mkdocs2notion/
│   ├── markdown/
│   ├── loaders/
│   ├── notion/
│   ├── cli.py
│   └── runner.py
│
├── tests/
├── pyproject.toml
└── README.md

Contributing

See agents.md for strict guidelines on:

  • development workflow
  • linting + typing
  • testing
  • commit rules
  • agent behavior

Contributions are welcome—but must follow these standards to maintain reliability.


License

MIT License.

Release Notes

Version Changes
v0.2.1 Fixed Readme and Installation Instructions
v0.2.0 Stable Release Version
v0.1.0 Preliminary Alpha Version

Metadata

Release files for mkdocs2notion 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mkdocs2notion 0.2.1
File Size Uploaded Provenance Actions
mkdocs2notion-0.2.1.tar.gz 608.5 kB Without provenance Details for mkdocs2notion-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mkdocs2notion 0.2.1
File Interpreter ABI Platform Actions
mkdocs2notion-0.2.1-py3-none-any.whl Python 3 none any Details for mkdocs2notion-0.2.1-py3-none-any.whl

Total release size: 644.8 kB

Release files / mkdocs2notion-0.2.1.tar.gz

Download URL mkdocs2notion-0.2.1.tar.gz
Size 608.5 kB
Tags Source
SHA-256 checksum
How to use checksums
1f3723300b7dd3a671a5847aa851ec556d34e6e8a84f2c232ae9791c372df8d7
BLAKE2b-256 checksum
How to use checksums
aad01286039f084065337a2234018f1233cac42b12c7f00029e81c1784ecc874
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.28.1

Release files / mkdocs2notion-0.2.1-py3-none-any.whl

Download URL mkdocs2notion-0.2.1-py3-none-any.whl
Size 36.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
202f900ab549b33819a5271dfad17e4cf05c94db41399af8d7469c8dbbfc5cce
BLAKE2b-256 checksum
How to use checksums
40d09c5a9fb1f24950e921cdc156b713194fc0b09e043079e3e9af10307ff79d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.28.1

Security for mkdocs2notion 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page