SWHarden.com

The personal website of Scott W Harden

Leaving WordPress

After fifteen years using WordPress, I’m leaving it for a simpler alternative: flat markdown files. There were several reasons behind why I made the change. First, I was disappointed with how frequently I had to update WordPress (and upgrade my database) to stay current with security updates. Second, I didn’t like how abstract post content was. The text of posts was stored in SQL tables and references to image URLs weren’t easily accessible (posts point to content IDs, the URLs of which were stored in another table), and images and media were scattered all over the filesystem because the default image placement changed several times over the years. Finally I found that logging in to a web front-end just to write a post was a bit of a barrier that prevented me from writing more frequently.

I have been very active on GitHub over the last few years and used their platform to share my code instead of this website. Lots of code and notes belong in repositories there, yes, but sometimes I create neat things which would be better represented as one-off posts on my personal website. Some of my repositories have collected notes like these, so I look forward to migrating a lot of that content here. My hope is that the new system I put together will make it easier to share content by writing it in Markdown using the editors I’m already working in every day.

Dynamic Markdown Parsing with PHP

The system I’m using now is pretty simple. Every post is a folder, and each folder contains a markdown file along with all of the images and files that post references. At the top of the markdown file is a little header which has information like title, date, and categories (tags). I use a PHP script route HTTP requests and if a requested folder lacks index.html but has index.md, I serve that using Parsedown to convert it to HTML. I also add a few tweaks to do things like convert YouTube links to embedded videos and add syntax highlighting to code blocks. Backups are easy (I just zip the folder), and the website could be committed to source control. I’m leaning away from this because it’s about 1GB (lots of images), but I’ll consider it. Also, the URL is just the path to the folder.

There’s a clear path toward generating a static site. If a folder lacks index.html, index.md is parsed and served. Switching to and from a static site can be achieved just by pre-converting all the markdown files to html and deleting them. I’ll probably keep working on refining the PHP script until the conversions are reliably processing like I desire, then convert most of the old pages to static files. The cool thing about this method is that it lets me serve some posts statically but others dynamically.

Wordpress (slow) Markdown (fast)

Performing the Conversion

The conversion from WordPress to Markdown was semi-automated, but still labor-intensive.

Along the way I had a few laughs at the ridiculousness of some of my old content. I think it’s probably a good thing to encourage teenagers to have personal websites, but I also encourage professionals and employers not to give too much credence to ramblings written by a person decades ago that Google happens to remember. I didn’t delete any content, but I marked most of the posts I made as a teenager as private and only exposed the ones that discuss this website.

History of this Blog

After reviewing all of my posts I now have a really good understanding of the evolution of the technologies I used to serve my website over the years. Here’s a summary of the major events: