Jason Sultana

Follow this space for writings (and ramblings) about interesting things related to software development.

Goodbye Wordpress, Hello Jekyll!

05 Sep 2020 » jekyll, blogging

What’s up with Wordpress?

G’day guys!

So, I first found Wordpress back in 2011. I was still at Uni and doing a bit of freelance on the side, and I thought that it was a fantastic platform to use with my clients; they were free to write their own content and customise the trivial parts of the website (like the menus and some minor styling) using the Wordpress GUI, while I was free to focus on programming a custom theme or plugin for them (what they usually paid me to do). Wordpress was so convenient to setup and and so customisable that I even ended up using it to host my own blogs and websites in the past as well. But no longer.

Don’t get me wrong, Wordpress does have its merits. It’s super easy to set up and easy to use, even for non technically minded users. It also has a huge ecosystem of themes and plugins, meaning that I often don’t need to develop a pretty layout and style for my website - somebody has already done it and released it as a theme, which I can easily customise to make it my own. If there’s a tiny piece of niche-functionality that I needed for the website, I could often just find a plugin that achieves it and install that, instead of having to write it myself. These points are even more attractive to end-users that aren’t developers, since doing it themselves is often not even an option. If you are a developer writing a website or blog for yourself though, I’d actually argue that you should not use Wordpress.

Oh yeah, what should I use then?

A couple of years ago, while working as a full-stack developer for Jeal (awesome company, by the way) I was reading the Front End Developers Handbook and heard the term “Static Site Generator” for the first time. If you’re unfamiliar with the concept, the idea is to write all of your content locally and use an engine to tranform it into a full static site that can then be hosted on a webserver. This is in contrast to a typical CMS like Wordpress, where you host the engine on the webserver and add content to it - it’s then up to the engine to produce a page dynamically on each request. Anyway, there are quite a few of these Static Site Generators, but the one that I’ll describe here is Jekyll.

You can read up on the details of Jekyll on their website, but the basic idea is that:

  1. You define some site variables in a file named _config.yml in your site root directory.
  2. You create bunch of HTML layouts and drop them under a _layouts folder. Each post and page should inherit from a layout.
  3. You can have includable html views defined in an _includes folder.
  4. Static resources like css and js can be included from anywhere.
  5. Posts can be written in pure markdown and placed in a _posts folder.
  6. Each post, page and template can use a combination of Liquid (the rendering engine Jekyll uses) as well as markdown. You can use user-defined variables defined in _config.yml, as well as injected and contextual variables provided by Jekyll, such as the current post and current page title.

When you’re done, you just run jekyll build on the command line, and the Jekyll engine will produce a fully-static website in the _site directory for you to upload to your webserver.

Why is this better than Wordpress?

I’m so glad you asked! To be fair, most of the points I’ll make here apply to any CMS, not only Wordpress, so I guess my real argument is for Static Site Generators over a traditional CMS. But my direct comparison is between Jekyll and Wordpress, since those are the two platforms that I’ve worked with the most personally.

1. Static sites are faster and more secure than dynamic sites

If you’ve ever run a Wordpress site, you’re all too familiar with the amount of spam email and spam comments you can get from day one. Wordpress accounts for about 25% of all websites on the web if I recall correctly, so it makes sense that so many people are targeting Wordpress sites. On top of the security, there’s the additional load time that Wordpress sites incur to read from the database, run through all of the registered plugins and theme hooks and finally render the content. Static sites have taken all this work and moved it to compile time instead of run time, so to speak, so the site should almost always load faster.

2. Code editor friendly.

You’re able to see, navigate and work on the entire website / blog from within one project or workspace in your favourite text-editor or IDE. For me, that’s VS Code. Sure, you’re able to drop a theme or plugin into a VS Code workspace, but when it comes to configuration or writing content, you’re forced to use the Wordpress GUI like a n00b. There’s a certain joy that comes with having everything viewable in VS Code.

3. Source control everything!

This is somewhat of an extension to the previous point, but you’re also able to source control the entire website or blog as well. That includes the configuration in _config.yml, as well as metadata (categories and tags) and perhaps most importantly - the content. Sure, you can run backups on Wordpress sites, but these are usually massive SQL dumps that are megabytes in size, and live outside your repository. With a static site generator project like Jekyll, everything can be source controlled with little effort.

Jekyll also has themes and plugins, so you’re not sacrificing extensibility moving from Wordpress, either.

Anyhoo, if you are a Wordpress dev and are still reading this, maybe I’ve convinced you to give Jekyll a try. I can’t recommend advising it to your end users (unless they’re tech-savvy), but I definitely do recommend it for yourself. And of course, this blog post was written in Jekyll :)

That’s all from me! Catch ya!

Related Posts