Prompt to turn exported CMS pages into MDX or markdown files
This prompt asks an AI assistant to read the saved HTML pages of your blog or CMS collection, copy each one into a markdown or MDX file with front matter for title, date and slug, and keep the body text exactly as written. New posts then become files instead of a new export.
Last reviewed
Key facts
- An export saves each CMS item as finished HTML, so the content is there but not in an editable form.
- Astro content collections are defined in src/content.config.ts with a loader such as glob().
- The assistant must keep the text as written and flag anything it cannot parse.
- Test status: not tested yet. The real export we used has no CMS collection pages.
The prompt
Paste this into Claude Code, Cursor, Gemini CLI or another AI coding assistant with your project folder open, and replace everything in square brackets first. See how to run it in each tool.
You are converting saved CMS item pages in ./exported-site/[COLLECTION_FOLDER] into markdown files in [OUTPUT_FOLDER].
FOR EACH PAGE
1. Read the HTML and find the title, publish date, author, summary, hero image and body.
2. Write one file named <slug>.md (or .mdx if the page uses components) with this front matter:
title, date (YYYY-MM-DD), slug, description, image, author
3. Convert the body to markdown. Keep headings, lists, links, images, tables and code blocks. Keep image paths valid.
4. Keep the text word for word. Do not improve, shorten or rewrite it.
IF A FIELD IS MISSING
Leave it empty and list the file and field in CONTENT_REPORT.md. Do not make up dates, authors or descriptions.
AFTER ALL PAGES
- Write CONTENT_REPORT.md: number of pages found, number converted, and every file that needs a manual look.
- Write REDIRECTS.md if any slug differs from the old URL path: old path, new path.
- [ASTRO ONLY] Add a content collection in src/content.config.ts that loads these files with glob() and checks the front matter fields.
RULES
- Start with three pages and stop so I can compare the output with the live pages.
- Do not delete the original HTML.How to run it
- Count the item pages first, so you know what to expect from the assistant.
- Send the prompt for three pages and compare each file with the live page line by line.
- Approve the batch run and read CONTENT_REPORT.md for the files that need a manual look.
- Add a route or collection that renders the files, then build and compare the result with the live site.
Front matter fields to keep
Keep the list short. Every field you ask for is one more thing the assistant can get wrong, and one more thing a template must handle.
| Field | Where it comes from in the HTML | If it is missing |
|---|---|---|
| title | The h1 and the title tag | Report the file |
| date | A time element or visible date text | Leave empty, do not invent |
| slug | The last part of the page URL | Use the file name and add a redirect line |
| description | The meta description | Leave empty |
| image | The hero or Open Graph image | Leave empty |
Verify the result
Count what went in and what came out, then compare a few files by eye. A mismatch in the counts is the first sign of a skipped page.
find exported-site/blog -name "*.html" | wc -l
find content/blog -name "*.md*" | wc -l
grep -L "^title:" content/blog/*.md*- The two counts match, or the difference is explained in CONTENT_REPORT.md.
- The last command prints nothing, so every file has a title.
- Three random posts match the live pages word for word, including links and images.
What can go wrong
- The assistant tidies punctuation or rewrites sentences. The word for word rule and the three-page check catch it.
- Embedded media and custom blocks do not convert to plain markdown. They land in the report for a manual fix.
- Slugs that change without a redirect lose their search traffic. Read REDIRECTS.md and add the redirects.
Frequently asked questions
Why convert CMS pages to files?
The export saves each item as HTML, so a new post needs a new export. With markdown files you edit text and rebuild, and the platform is no longer in the loop.
Can I get the raw CMS data instead?
For Webflow, the CMS to CSV tool converts pasted collection JSON into a CSV file. The prompt works from the saved pages.
MDX or plain markdown?
Use plain markdown unless a post needs components. MDX adds a build step and a place for mistakes.
How do I keep old URLs working?
Keep the slug the same as the last path segment, or add a redirect. See the SEO migration guide.
Official documentation
Free tools for this job
- Webflow CMS Export to CSVPaste Webflow CMS collection JSON and convert it to a downloadable CSV.
- Website MD File GeneratorConvert any webpage into a clean Markdown file optimized for AI ingestion.
- Markdown ConverterConvert files, pasted text, webpage content, Notion, and Google Docs into Markdown.
- Redirect Map BuilderBuild an old-to-final redirect mapping from URL lists.
Start with the files
Prompts work best on a WebExport download of your site. Paste your public URL into the export form and get a ZIP. The Free plan covers 1 site, 5 exports a month, 15 pages and 20 MB per export. Professional is a $9.99 one-time purchase with unlimited pages.