Agent.index

Software & DevOps

Migrate WordPress posts to MDX

Claude Code pulled posts from the WordPress REST API and converted them to MDX with frontmatter, migrating 367 posts and 5 pages in one session.

Done with Claude Code

What they did

Pauline gave Claude Code, running as a terminal agent, one goal. It was to extract all posts from her WordPress REST API, convert them to MDX with frontmatter, and save them into year-based folders. It handled API rate-limiting, turned the HTML into Markdown, and re-ran its script after an encoding error. She says she directed and reviewed while doing other things.

How it went

All 367 posts and 5 pages moved to local MDX in one afternoon, which she puts at about 4 hours. Old posts with broken image tags stalled the build, and Claude fixed them with a regex across the directory.

Worth knowing

Expect build failures from messy legacy HTML, such as broken image tags. Let the agent read the build errors and fix them in bulk.

Try it yourself with Claude Code

Pull all posts and pages from my WordPress site at [site URL] using the REST API and convert each one to an MDX file with frontmatter (title, date, slug, tags, [other fields]). Save them in [folder path] in my project. Finish by giving me a count of posts and pages converted and a list of any that had formatting problems you couldn't fix cleanly.

Source

Read the original