Skip to main content

WordPress to Markdown

A modular Python library for converting WordPress content into structured, Markdown (including Obsidian-compatible notes) files.


Overview

This project provides a clean and extensible pipeline to transform content from WordPress into local files suitable for knowledge management systems like Obsidian.

Core pipeline:

WordPress API → JSON → Process → Assemble → Write

Features

  • Fetch posts from WordPress REST API
  • Normalize and process content
  • Convert posts into structured objects
  • Export as Markdown files
  • Build output in per_post or book mode
  • Optional YAML frontmatter generation
  • Modular architecture (easy to extend)

Project Structure

wordpress-to-markdown/
├── src/wordpress_to_markdown/
│   ├── cli.py
│   ├── commanding.py
│   ├── config/
│   ├── core/
│   ├── importer/
│   ├── processors/
│   ├── sources/
│   ├── assembler.py
│   └── writer.py
├── tests/
├── config.json
└── pyproject.toml

Installation

Requires Python 3.10 or newer.

Install from PyPI (after the first release)

pip install wordpress-to-markdown

Install from GitHub (available now)

pip install git+https://github.com/Aues12/wordpress-to-markdown.git

Clone the repository

git clone https://github.com/Aues12/wordpress-to-markdown.git
cd wordpress-to-markdown

Quickstart

(Optional but recommended) Create and activate a virtual environment:

python -m venv venv
source venv/bin/activate

Development installation

With pip:

python -m pip install -e '.[dev]'

With uv (using uv.lock):

uv sync --locked --extra dev
uv run wordpress-to-markdown --help

Dependencies:

  • requests
  • PyYAML
  • markdownify

For running tests:

  • pytest

Usage

1. Fetch data from WordPress

from wordpress_to_markdown.importer.wordpress_api import export_posts_to_json

export_posts_to_json(
    base_url="https://your-site.com",
    output_file="data/imported.json"
)

Use this manual fetch step when you want to generate or refresh data/imported.json outside the CLI workflow. In normal usage, wordpress-to-markdown already checks for the JSON file and fetches it automatically when needed, or when you pass --refresh.


2. Configure the CLI

Use --config /path/to/config.json to select a configuration file. Relative json_file and output_dir paths are resolved from the configuration file's directory, not the shell's working directory.

Create/edit the config.json file in the project root:

{
  "wordpress": {
    "base_url": "https://your-site.com"
  },
  "paths": {
    "json_file": "data/imported.json",
    "output_dir": "output"
  },
  "frontmatter": {
    "include_frontmatter": false,
    "fields": [
      "title",
      "date",
      "modified",
      "slug",
      "category_names"
    ]
  }
}

3. Run the pipeline

wordpress-to-markdown

This will:

  • Load config.json
  • Reuse existing JSON or fetch fresh data from WordPress
  • Load JSON
  • Process posts
  • Assemble output
  • Write Markdown files to the configured output directory

Available CLI options:

  • --refresh fetches fresh data from WordPress before building
  • --order {newest,oldest} controls post selection order before limiting
  • --write_order {newest,oldest} controls ordering inside the written output
  • --limit N limits the number of posts to build
  • --mode {per_post,book} switches between one-file-per-post and combined book output
  • --frontmatter includes YAML frontmatter in the assembled output
  • --excerpt includes each WordPress excerpt before the post content (disabled by default)
  • --content-format {markdown,html} converts post and excerpt HTML to Markdown (default), or preserves the imported HTML inside the .md output

Cached exports created before excerpt support do not contain this field. Use --refresh --excerpt once to fetch excerpts from WordPress and rebuild them.

Examples:

# Build the 10 newest posts as individual markdown files
wordpress-to-markdown --order newest --limit 10 --mode per_post

# Build a single combined book in oldest-to-newest order
wordpress-to-markdown --order newest --limit 20 --write_order oldest --mode book

# Build individual files with WordPress excerpts below each title
wordpress-to-markdown --mode per_post --excerpt

# Preserve imported HTML in Markdown files
wordpress-to-markdown --content-format html --excerpt

Testing and packaging

GitHub Actions runs the test suite with pip and uv on Python 3.10–3.13, then builds and checks both distributions. It also tests the installed wheel outside the repository.

pip install -e '.[dev]'
python -m pytest
python -m build
python -m twine check dist/*

The implementation lives in src/wordpress_to_markdown/; import modules through wordpress_to_markdown. For example, from wordpress_to_markdown.config.loader import load_config. Use wordpress-to-markdown --config /absolute/path/to/config.json from any working directory; paths inside the config are relative to that file.

Testing

Run the test suite with:

python -m pytest

If pytest is not installed yet, install it with:

pip install pytest

Core Concepts

Post

Represents content during processing.

DocumentUnit

Represents write-ready output.

Pipeline

A sequence of transformations applied to each post.

Assembler

Defines how posts are grouped (e.g., per_post, corpus).

Writer

Handles output format (e.g., markdown, docx).


Current Capabilities

  • per_post assembly
  • Book assembly
  • Markdown export
  • Turkish-aware slug generation
  • Basic metadata normalization
  • HTML to Markdown conversion
  • Optional YAML frontmatter
  • Config-driven output directory

Future Roadmap

Processing

  • Markdown cleaning
  • Link conversion (URL → wikilinks)

Assembly

  • Corpus mode

Writer

  • Additional output formats

Design Principles

  • Modular architecture
  • Clear separation of concerns
  • Stateless processing
  • Extensibility over complexity

Example Output

output/
├─ post-1.md
├─ post-2.md
└─ post-3.md

License

MIT


Final Note

This project is designed as a foundation for building flexible content pipelines and personal knowledge systems.

Metadata

Release files for wordpress-to-markdown 0.1.0

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

Source distribution (sdist)

Source distribution for wordpress-to-markdown 0.1.0
File Size Uploaded Provenance Actions
wordpress_to_markdown-0.1.0.tar.gz 19.5 kB With provenance Details for wordpress_to_markdown-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for wordpress-to-markdown 0.1.0
File Interpreter ABI Platform Actions
wordpress_to_markdown-0.1.0-py3-none-any.whl Python 3 none any Details for wordpress_to_markdown-0.1.0-py3-none-any.whl

Total release size: 41.3 kB

Release files / wordpress_to_markdown-0.1.0.tar.gz

Download URL wordpress_to_markdown-0.1.0.tar.gz
Size 19.5 kB
Tags Source
SHA-256 checksum
How to use checksums
ac315d8995b3364c070bd1744ba8e10890d6c992465b0ea3b430d219f2ce52c7
BLAKE2b-256 checksum
How to use checksums
4cffb5a525523eb09153ef2f14a626d477cdeacadb0a4a00687f43c7ee5dfcda
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.

Transparency log

Release files / wordpress_to_markdown-0.1.0-py3-none-any.whl

Download URL wordpress_to_markdown-0.1.0-py3-none-any.whl
Size 21.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f4d356b0236134651f5279c55216cd00967b6b9c2cd4e8178b4a4e7d2cd61a70
BLAKE2b-256 checksum
How to use checksums
bc40e335d4f7b7b46304f7da75fbfd7667e9205290ed83ec643f7b21aa045bcc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.

Transparency log

Security for wordpress-to-markdown 0.1.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for wordpress_to_markdown-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 9, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

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