By Jason Yu, form Unsplash

Don’t run your WordPress blog on Heroku

There are very few reasons as to why one would want to run a WordPress blog on Heroku which uses a Postgres database instead of MySQL (the database structure WordPress uses by default), ours was mainly to save time. As a web-based technology company we already have a handful of servers running our multiple production, staging and continuous integration environments for different projects, we really didn’t have time to run another server and database just for a blog, neither did we want to attach it to one of our existing sites since we wanted to keep projects clean. So the simplest, quickest, and less finicky solution was to run WordPress on Heroku, or at least we thought so.

Yes, there are many different more lightweight content management systems we could have used like Perch or Craft. Yes, we could have bought a simple hosting service and used a one click solution to install WordPress, but those solutions wouldn’t have worked well for our scenario. We chose WordPress because that was the CMS the marketing team were familiar with, and we didn’t want our developers’ time wasted on uploading images and tweaking blog posts. We also didn’t go down the established hosting service route because we’d already paid for, were very familiar with, and already had a few regularly used projects on Heroku, so using that was the default choice.

After we made this decision, research was done to figure out how to achieve it. This GitHub repo by Matt Hoofman was incredibly helpful in getting us started and is actually really simple process, as long as you’re comfortable running multiple terminal commands. All it required is cloning a repo, and uploading it to Heroku. Now, people who are reading this who have used Heroku before probably know a thing or two about the techniques to keep dynos awake, there are enough articles out there explaining how to do it so I won’t go into it, but it’s something we had to do to speed up the site. From this point onwards I will go through a few issues you might come across if you choose to go down this route.

1) The most important plugin you will need in wp is the one that prevents the user from update anything core to WordPress. Do not update WordPress core at all, we found out the hard way. Luckily we had a backup. Since WordPress is strongly tied to MySQL, all the updates from WordPress HQ deal with that database structure and therefore wouldn’t work with the Postgres setup Heroku requires, therefore an update would try to update MySQL and break the Postgres setup. Also, hide all plugin updates. Updating or adding a plugin isn’t as simple as clicking a button in the wp-admin backend, it requires a developer to download the latest plugin, add it to the repo, then push that to Heroku. And we wouldn’t want anyone non-technical clicking on it.

2) Once again no MySQL means nowhere for images to be saved so we ended up using aws and it’s respective WordPress plugin but there are other great plugins that do a similar thing. Somewhat linked to this we also came across an issue with long URLs mainly for page links. In essence, if a blog post included an over say–50 character URL it just wouldn’t work, it would display raw HTML in the post.A simple solution was to use bitly.com which worked well.

3) The final major problem we encountered was to do with SEO. Those who have tried SEO in WordPress have most likely heard of Yoast, which is by far the most popular SEO plugin out there. Installing it to our setup wasn’t an issue, I’ve already explained the process for installing plugins above, but for some reason the introductory popover wouldn’t go away, which meant the plugin wasn’t usable. The user could click on ‘next’ button several times, get to the end but after clicking ‘finish’, it would redirect you to a page that doesn’t exist anywhere on your site, then back to the WordPress admin page. Nothing would have saved which meant the user would have to go through the series of popups again. After hours of Google searches and trying out different suggestions, I had to take matters into my own hand and manually edit the plugin file to disable all the popovers. Although this worked, it probably wasn’t the best way to get around it.

Although there will usually be problems with adding and updating a blog of any kind, the issues mentioned above are possibly the most random I’ve ever encountered when dealing with WordPress. There are still a handful of problems I didn’t list and some I’m sure we will encounter after this article has been published. If these issues seem like something you can handle, then you’re more than welcome to try this method out if not, I’d advise sticking to the recommended Wordrpess setup.

Happy blogging.