
Migrating from Wordpress to Astro
The first “professional” website I ever created - a small info page for my fathers business - was purely HTML and CSS. Hand-written in a text editor without any autocomplete or other support.
After many years operating on WordPress, this website is now also a purely static page, built upon Astro. In this blog post, I explain the why and the how.
How it started
When I created my first personal website, a blog under my old domain carstenwindler.de many years ago, it was clear to me from the very beginning that I had to use some sort of content management system. Simply because that’s what I was proficient with back then, having worked as a freelancer mostly with Typo3, that notorious Open-Source-CMS monster.
WordPress back then was already strong, providing good-enough standard templates, and a rich collection of plugins. Yeah, the code quality … WordPress has never been the best example of good PHP code, and although we can claim that PHP still drives most sites of the internet, I think it’s also true that WordPress, and particularly the plugins, are partly responsible for the terrible reputation of this language.
I, for example, still get sweaty palms when I think of the code of the WooCommerce shop from back in the day, a plugin I had to deal with for a small side project.
But hey, WordPress was easy enough to get my first results up and running, and that goal was achieved very well.
How it went
Over time, the whole ecosystem became enshittified (greetings to Cory Doctorow). More and more plugins became commercial, and while I support paying money for software, I’m no fan of the subscription model. The constant fear of being hacked if I don’t check and update my installation every other day was annoying. Finally,Project Gutenberg, this - for me - extremely annoying editor, was the final piece that led to my decision to leave WordPress.
I just wanted to write, not to maintain another web app. Something I do enough in my day job. Static websites also tend to have a smaller carbon footprint, since content is only generated once, unlike dynamic pages (ok, caching, yes I know, it all “depends”).
A website generated by a static website generator sounded perfect for my very limited needs. In between, I’ve fallen in love with Markdown, so the goal was clear: migration to Hugo! Mostly because it was the only tool of that kind that I knew of at that moment.
It took me a couple of years, though, because I never really found the time. Or the motivation. Until LLMs entered the game.
Current state
My experience with AI-assisted coding finally made me give it another try. I tried Astro.js instead of Hugo, though, since it was technically closer to the stack I’m used too.
After a quick PoC, it was clear to me that my goal was finally achievable with an overseeable amount of time and effort.
So I devised a masterful plan:
- Excerpt all content from my old WordPress blog
- Migrate that content to Markdown
- Set up the new page with Astro
- AI-magic
- Success
WordPress to Markdown
Looks like I was not the only person with the goal of moving away from WordPress, so I, e.g., came across a tool which exported my blog posts and pages into ok-ish Markdown, plus kept all media assets organized. Yay, 2 steps at once, thanks a lot to Lonekorean! It’s FOSS!
Surely the results were not perfect but good enough to continue. Since my blog is relatively small, it took me a couple of LLM-assisted sessions to clean up most of the pages and posts.
The Astro project
Setting up Astro with AI is pretty straight forward, but of course you have to still know what you are doing, and especially probably the hardest part, know what you actually want!
Eventually, I ended up using the Astro starter kit as theme and these packages:
- @astrojs/markdown-remark
- @astrojs/mdx
- @astrojs/rss
- @astrojs/sitemap
- @jdevalk/astro-seo-graph
- @jdevalk/seo-graph-core
- astro
- astro-pagefind
- pagefind
- reading-time
- satori
- sharp
MDX is basically Markdown with embedded JavaScript. Sounds scary, I know. I actually rather keep any logic out of my Markdown files, but sometimes it’s just helpful to have the extra flexibility.
Other than that, I don’t need much. Sitemaps, RSS feeds, page search, and so on are generated once during the build.
For page insights, I’m using Matomo.Privacy first, no cookies, no user tracking, or anything like that on my site, just basic JavaScript for site statistics.
SEO considerations
Of course I also wanted a fast and technically clean solution. Visually appealing, but lightweight. SEO/GEO-friendly. Minimal JavaScript.
You can’t go faster than static HTML, so the page load part was more or less solved. I’m no frontend developer, but with AI I was able to quickly solve some of the issues reported by Lighthouse (some are still to go, I know).
Using an SEO skill from Yoast turned my blog into an SEO wonderland (or at least that’s what’s being promised). I’m not fully done here as well; right now I first want to deliver some more content, since I haven’t been that active lately, then iterate on the remaining issues.
I will take some time to see the actual results. Of course, I’m not naive when it comes to dropping visitor rates caused by AI, e.g. because of the AI-generated summaries, so I have to take that into account as well.
Hosting
It shouldn’t be that difficult to find a hoster for a bunch of static files; however, I had some requirements: my page must be hosted in Europe and using energy from renewables, since I want to keep my digital footprint low.
I still have an account at a small German shared hoster, and right now, I’m just using plain old SFTP to update my page. It feels like time travel back to medieval times, and not even being able to use rsync is a bit clumsy. For now, it works, but I guess at some point I need to find an alternative.
“Why don’t you just use GitHub Pages?”, you say? I’m glad you asked: Because I want to get away from GitHub.
Code repository
The day GitHub was bought by Microsoft, I made the decision to at least try to find alternatives one day. And oh boy, that is not easy.
I could move to GitLab, and that still is my backup plan. However, it is an US company, too, so it bears some risk. And I was curious about other alternatives.
One interesting project surely is Forgejo, a self-hosted GitHub clone software forge. I didn’t want to host my own instance, though, so I gave Codeberg, a Forgejo instance hosted by a German non-profit organization.
Codeberg also offers hosting for static pages (https://codeberg.page/) and CI/CD. I haven’t really explored both yet, but will do so soon.
Was it worth it?
I’m really happy with the results, given the time I spent on it. Surely I always see many more things I could do on my blog (and my issues list on Codeberg is long…), but after all, it is just a small, unimportant website.
Not having to worry about security issues, and being able to use Markdown for writing is such a relief. I have full control about the page content and don’t have to deal with content blocks and such.
The page speed is amazing, although that was to be expected due to the nature of a static website.