/ TECH, WEB DEVELOPMENT, WORDPRESS, JEKYLL

Migrating from Wordpress to Jekyll

I have been using Wordpress for my site for the last 10 years. Is it time for a move to a new technology?

Reasons for switching

My primary reason is that I have used Wordpress for the last 10 years and over the years have fiddled so much with plugins, extensions and themes, split the site into two separate sites. That I do not know how my old content looks like and if all articles are still displayed correctly.

Of course I would have the possibility to just set up a fresh new wordpress site. However I do not have a lot of posts (around 80+) and I only use my site for simple blogging.

  1. Static Site generators One of the core differences between Wordpress and Jekyll is that Jekyll simply generates a fixed HTML/CSS website. This small change allows the site to be cached more easily and distributed over a CDN for example. - Yes, you can set up something similar with Wordpress. However you need to set it up.

  2. Switch to Serverless With the switch away from Wordpress you are able to host your site either on Github or Gitlab. You do not need a Database or PHP you only need to configure the Gitlab Pipeline or the support for github-pages. This move would also immediately take care of all the CDN setup etc.

  3. Getting rid of PHP and MySQL By switching to Jekyll, suddenly you do not need a database anymore as all articles are simple markdown files. The other thing that is not needed anymore is PHP. With Jekyll you are basically only are dealing with HTML.

You are not saving a ton of versions in your Database how the article changed over time, you simply are using Git as your version control. Additionally since you are checking out your git-repository you immediately have a complete backup of your website locally and you can (for the most part) avoid the complicated setup of a wordpress backup system. (Basically you can put your git repo in a Dropbox folder and you have a dropbox backup).

Downsides

If you are working with multiple people, they all have to start learning markdown and if they are not familiar with git they are in for a ride. You need to setup your git-repository so that everyone can contribute without breaking the site.

You are loosing the ability to access all the wordpress plugins and features.

Conclusion

Basically for my use case, a very simple blog, where only a single person is editing it. A migration to Jekyll is possible and makes sense. Now let’s take a look on how to make it possible.

Set up Jekyll

When setting up Jekyll you have two different options:

  1. Follow the Quickstart Instructions
  2. Search for a Theme Jekyll Themes or themes.jekyllrc.org and follow the instruction of the theme (usually it is a simple fork of the project)

Plugins

Starting out I am only using one plugin the jekyll-postfiles this allows you to manage your images a little nicer instead of having a folderstructure that allows you to keep your image assets with your markdown file.

  1. Add to your Gemfile:
    group :jekyll_plugins do
      gem 'jekyll-postfiles'
    end
    
  2. Run bundle install

Wordpress to Jekyll

The first thing you probably will want to do is export all of your posts here somebody already created a useful Jekyll-Exporter Plugin.

  1. You install it and activate it
  2. Then go to Tools > Export to Jekyll
  3. It will then create a large Zip file with all your media uploads and posts and pages.

The plugin does not know about Projects, so they will be ignored and you will have to transfer your projects manually.

Converting your posts

In the exported markdown files you will have a lot of html code, sometimes it is ok sometimes it is really ‘wordpress’ generated nonsense. I discovered in my long history that I used very many different types of plugins to display source code. Thus there are various markups and html tags that do nothing.

If you want to convert the html to more readable markdown you can use a turndown converter.

Conclusion

The moving from Wordpress to Jekyll is not straightforward and depending on the amount of posts you will need to adjust a lot of posts that they still function the way you intend in jekyll.

You probably will have to write some scripts to convert your posts a little more efficiently. You can download my script here (However it was just a very quick slapped together effort with minimal testing and minimal documentation)

Credits

Image: Official Jekyll Logo Twitter