Skip to content

WordPress to Astro Migration

Cover Image for WordPress to Astro Migration
Published on underTechnology

Maintaining my Wordpress site has been a growing pain in the butt over the years. Plus the massive hacks lately prompts me to think again to move the site forward. The time baby sitting it is far more than writing anything to it. Hence I decided to move from Wordpress to Astro.

The Goal

  1. Improve site vitals - current setup with Next.js with headless Wordpress is still slow.
  2. Preserve all text content
  3. Preserve all images
  4. Preserve all comments
  5. Sitemap.xml
  6. RSS
  7. Faster editing workflow
  8. Less maintenance

The Process

Export from WordPress &

First you need to export all content from WordPress MySQL database.

Wordpress export menu

Make sure to export ALL types of content.

Wordpress export options

When it’s ready, the XML will be downloaded. At this point, you will need to do the most painful thing - download the entire wp-content/uploads folder. You will need SFTP or terminal access or some cPanel alike web interface to download the entire folder of uploaded media. It took me an hour or so to download every bits.

Wordpress export xml

Bring in your AI agent

With the help of OpenCode, I asked it to create a tool to extract exported WordPress content in XML to individual MarkDown files for Astro content consumption.

Now I have the Python script to crunch the XML and split into proper folder structure for Astro to consume.

Next asking OpenCode to create the Astro project in the location of your choice. It will construct the Astro content model for you as well. In my case of migrating from a Next.JS using WordPress as headless CMS, I have all the components ready to convert to Astro. Building from nothing will definitely take longer time.

Once it’s setup, need a do a lot of manual check. Initial round, there was missing image gallery and handling for older content. Depends on what you have in the content, you may need to ask your agent to cater for special code blocks.

The skill is yours too

Now that I have completed the migration, I have created a skill for the above process.The migration skill is available at GitHub

Workflow

Time to test the local site at http://localhost:4321/ and you can tell OpenCode to use the skills impeccable to check the site as follow:

Use @impeccable critique, and fix the Astro site http://localhost:4321/

BTW, there are some code blocks (class) spotted that need extra care for my case:

  1. wp-block-embed-youtube
  2. wp-block-embed
  3. [gallery]

You will need to decide how to deal with it. For instance, the wp-block-embed-youtube is the embedded YouTube content. So the rendering I’m looking is to just replace it with iframe and point to this url and some style adjustment.

For the gallery, I’d replaced with listing the images out on the page.

At this point, the migration is mostly ready and you can push to GitHub to deploy to Netlify, Vercel and whatnot. You can also setup GitHub workflow to build and deploy to your own server.

If you need some content be password protected or unlisted content, that will restrict the deployment platforms to Netlify or Vercel or your own VPS that allows server actions.

By no means, this process is for everyone without some webdev background even though AI agent does help a lot in the process.

Model used: Iceman Free from OpenCode 2.4.3

The Achievements

At least I can cross out some items confidently.

  1. Improve site vitals - so far I like what I see comparing to the previous implementation.
  2. Preserve all text content
  3. Preserve all images
  4. Preserve all comments
  5. Sitemap.xml
  6. RSS
  7. Faster editing workflow
  8. Less maintenance - I hope from now on there is much less life threatening CVEs in the future.

The Missing Bits

Since I’m moving away from WordPress, there is no more commenting to go with. Not that a long of people interact. My thinking is if there is anything people like to interact with the post, they may just well ping me in X or Github or Mastodon or even LinkedIn.

The Next Step

Give it enough running time, I shall retire the WordPress for good in near future.

That’s a wrap for now.


More Stories