Menu

1 / 2

How I move 300 WordPress posts into Astro content collections

DEV Community: webdev·Linc·about 15 hours ago
#qGa7hBVo
#devtowebdev#devto#dev#client#converter
Reading 0:00
15s threshold

Last month I moved a client with about 300 blog posts off WordPress. The design was the easy bit. The content is what eats your week if you dont plan it. Here is the workflow I use now for getting those posts into Astro content collections.

1. Export, then look before you convert

I export the WordPress XML from Tools > Export and also pull the posts through the REST API ( /wp-json/wp/v2/posts?per_page=100 ). The XML has the raw content, the API gives me clean fields for slug, date, categories and featured image id. Both go in a migration/ folder in the repo.

Before converting anything I open ten random posts and check what is actually in them. Page builder shortcodes, [gallery] , embedded forms, inline styles. You want to know that before you write a converter, not after.

2. Convert to Markdown, keep the frontmatter boring

A small Node script with turndown does HTML to Markdown.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.