我打造了一款會自行檢查結果的 WordPress 遷移工具
I built a WordPress migration tool that checks its own work
wp-move 是一款唯讀 WordPress 遷移工具,可將內容轉成 Markdown,並核對文章、媒體、圖片引用及站內連結是否完整;發現缺漏時會輸出報告並以 code 2 結束。在本機 WordPress 7.1.3 官方主題測試資料中,它遷移了 144/144 篇文章與頁面、37/37 個媒體原檔,沒有缺圖或失效站內連結。工具目前只在主題測試資料上測試,尚未在真實正式網站驗證。
Most WordPress migration tools end the same way: export finished. Finished is not the same as complete. Did every post make it? Every image? Does every old link still land somewhere?
What breaks when people leave WordPress
Before writing code, I collected 300 GitHub issues from four popular WordPress export tools and sorted them by title:
- 27% were the tool itself crashing, timing out, or failing to install
- 14% were about images
- 12% were about URLs and permalinks
- 10% were about HTML turning into broken Markdown
I also read 639 Hacker News comments from 21 threads about leaving WordPress. 111 of them describe a concrete difficulty. The most common were build and deploy work afterwards, losing comments, getting content out, and non-developers losing the ability to edit.
What wp-move does
- Reads posts, pages, media, categories and tags through the REST API. It only reads.
- Converts each post to Markdown with front matter. Anything Markdown can't hold (tables, embeds, forms) stays as HTML and is listed.
- Downloads images hosted on your site and rewrites their paths.
- Maps every old URL to its new path and writes
_redirectsand nginx files. - Writes
report.htmlandreport.json, and exits with code 2 if posts, media, image references or internal links are missing.
uvx --from git+https://github.com/AidanKR/wp-move@v0.0.1 wp-move pull https://your-site.example --out out
Results on the demo site
On a local WordPress 7.1.3 with the official theme test data:
- 144/144 posts and pages, including a draft and a scheduled post
- 37/37 media originals
- 0 pages under 95% of their words, 0 missing images, 0 broken internal links
- 164/164 old URLs redirect to the new path through nginx (282/282 with
--url-style slug)
Then I broke it on purpose: I deleted one image and one post from a copy. The report showed 143/144, 36/37, and 3 missing image references, and the command exited with code 2.
What it does not do yet
- It has been tested only on the theme test data, not on real production sites.
-
_redirectshas not been tested on Netlify or Cloudflare Pages yet. - No comment migration, no category or tag pages, no theme. Shortcodes are detected but not converted.
If you own a WordPress site, try it and open an issue with what the report got wrong (leave out anything private).
GitHub (MIT): https://github.com/AidanKR/wp-move
Demo video (6 min): https://youtu.be/Nh5L_zPIQbI
Disclosure: this post was drafted by an AI agent (Claude) that also helped build the tool. Every number above comes from measured runs documented in the repository README.
來源:DEV Community · dev.to