wordpress中文章转为markdown的方式
1.安装node.js
自行百度下,windows、mac、linux方式安装各有不同
我本地node版本为
wulili@wulilideMacBook-Air mycode % node -v
v19.1.0
2.安装hexo-cli
wulili@wulilideMacBook-Air Desktop %npm install -g hexo-cli
wulili@wulilideMacBook-Air Desktop % npm list -global
/opt/homebrew/lib
├── cnpm@9.1.0
├── hexo-cli@4.3.1
└── npm@8.19.3
3.创建hexo项目
创建项目目录
wulili@wulilideMacBook-Air mycode % mkdir hexoDemo
wulili@wulilideMacBook-Air mycode % cd hexoDemo
初始化博客
wulili@wulilideMacBook-Air hexoDemo % hexo init
INFO Cloning hexo-starter https://github.com/hexojs/hexo-starter.git
INFO Install dependencies
warning hexo > warehouse > cuid@2.1.8: Cuid and other k-sortable and non-cryptographic ids (Ulid, ObjectId, KSUID, all UUIDs) are all insecure. Use @paralleldrive/cuid2 instead.
INFO Start blogging with Hexo!
wulili@wulilideMacBook-Air hexoDemo % ls -l
total 160
-rw-r--r-- 1 wulili staff 0 9 21 15:39 _config.landscape.yml
-rw-r--r-- 1 wulili staff 2441 9 21 15:39 _config.yml
drwxr-xr-x 212 wulili staff 6784 9 21 15:40 node_modules
-rw-r--r-- 1 wulili staff 615 9 21 15:39 package.json
drwxr-xr-x 5 wulili staff 160 9 21 15:39 scaffolds
drwxr-xr-x 3 wulili staff 96 9 21 15:39 source
drwxr-xr-x 3 wulili staff 96 9 21 15:39 themes
-rw-r--r-- 1 wulili staff 70715 9 21 15:40 yarn.lock
静态部署
wulili@wulilideMacBook-Air hexoDemo % hexo g
INFO Validating config
INFO Start processing
INFO Files loaded in 52 ms
INFO Generated: archives/index.html
INFO Generated: archives/2023/09/index.html
INFO Generated: archives/2023/index.html
INFO Generated: index.html
INFO Generated: js/script.js
INFO Generated: css/style.css
INFO Generated: js/jquery-3.6.4.min.js
INFO Generated: fancybox/jquery.fancybox.min.js
INFO Generated: fancybox/jquery.fancybox.min.css
INFO Generated: css/images/banner.jpg
INFO Generated: 2023/09/21/hello-world/index.html
INFO 11 files generated in 110 ms
启动server,就可以http://localhost:4000/访问了
wulili@wulilideMacBook-Air hexoDemo % hexo server
INFO Validating config
INFO Start processing
INFO Hexo is running at http://localhost:4000/ . Press Ctrl+C to stop.
^CINFO Bye!
4.wordpress中导出文章
导出文章为一个xml文件

5.使用hexo-migrator-wordpress转换为markdow
在项目目录下安装hexo-migrator-wordpress
wulili@wulilideMacBook-Air hexoDemo %npm install hexo-migrator-wordpress --save
把导出的xml转换为markdown
wulili@wulilideMacBook-Air hexoDemo % hexo migrate wordpress /Users/wulili/Downloads/WordPress.2023-09-21-1.xml
INFO Validating config
INFO Analyzing /Users/wulili/Downloads/WordPress.2023-09-21-1.xml...
INFO Post found: 世界,您好!
INFO Post found: 测试文章
INFO Post found: golang程序后台运行的方法
INFO 3 posts migrated.
查看生成的markdown
wulili@wulilideMacBook-Air hexoDemo % cd source/_posts
wulili@wulilideMacBook-Air _posts % ls -l
total 24
-rw-r--r-- 1 wulili staff 2848 9 21 16:32 golang程序后台运行的方法.md
-rw-r--r-- 1 wulili staff 395 9 21 16:32 hello-world.md
-rw-r--r-- 1 wulili staff 194 9 21 16:32 测试文章.md
wulili@wulilideMacBook-Air _posts %
版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。
转载请注明来源:wordpress中文章转为markdown的方式 - 多知在线