alt The editing and preview screen on my custom CMS

I made my own CMS

When it came time to update this site and dig through backups to find lost articles, it occurred to me I need a better CMS for the writing section of my site. I ended up writing my own, and hopefully there’s a good reason.

Normally by default I turn to Wordpress, which has served me well for medium sized websites. I’ve used on here before but found it overkill for my needs. I’m not knocking Wordpress, and I’m sure I didn’t make something better, but it’s fit for purpose.

I did a quick look around scouting for a simple blog platform, or tutorials to write my own, and I came up short. I surmised a learning curve to set up another CMS and build the templates from the existing CSS and plain-html pages, and felt the best approach was to go custom.

Medium wasn’t the correct fit either. I have a few articles there already and certainly get better traffic on their platform, but I would need to backdate posts from their original dates and Medium doesn’t like that so much.

My go to backend language is PHP (I don’t know Rudy, Python or Java), and it was especially easy to pick up after a long break. It’s a lot easier to insert PHP tags into a finished html template and echo out the content from the source.

Previously I’ve avoided OOP-PHP. I’ve used PHP since 2000-01 and I’ve never really understood the objects for whatever reason. But I was pleasantly surprised when I wrote out a PHP class and it worked. Then I realised it looked exactly like Swift and I’ve been dabbling in iOS development for a couple of years.

I gave up on the database too. Mysql also seems as much overkill as Wordpress, it needed to be simpler and leaner. I wanted to explore simple light files. (To be fair my database knowledge doesn’t extend far enough to know if a single-table five-column database would be leaner.)

Initially I played around with creating JSON files as I had experience parsing JSON in PHP and like the organisation of the content. I began making the structure too complicated as I made every paragraph a separate entity.

This proved difficult to edit in the little editor I made. The second iteration used markdown since I’ve become used to the format in various note taking apps. Having previously passed on a markdown based tutorial due to its complexity (it had dependencies and too many directories), I stripped the idea down and repurposed the code I’d already written. Parsedown amounts to about three lines of code and that’s it (include, create object, echo).

Finally I set up some security. And uploaded the files. Done.

All told it was a few hours over a couple of evenings. Installing Wordpress would have been faster but I would have learned nothing.

So right now if you’re actually reading this self-serving sardonic drivel, you’re reading it on my custom CMS. I’m not planning to upload it to a gitbucket, but maybe I’ll eventually share some cleaned up code (once I learn how to show code in markdown).