Use WordPress as a Static Website Generator

By , Updated: June 5, 2017

That’s one of the reasons why more and more people turn to static website generators. Jekyll is one of the most popular ones, which you can use to host your whole website or blog on GitHub Pages and push your new content with one command. The downside? For the laymen it’s not easy (to say the least) to set it up, and even for developers it can be time-consuming. If you have a free afternoon to learn more about Jekyll then take a look at this article by Barry Clark, it’s the most detailed tutorial on the topic that I know of.

However, if you’d rather just speed up your current WordPress site, you can do that too! You just have to remember that if you use WP in that way, you’ll have to make sacrifices: there won’t be any “real-time” dynamic content on your site, at all. No “recommended articles for you” widget that’s different for each visitor, you can’t use WordPress’s built-in commenting system and so on. Everything that is server-side (PHP) generated will become static and updated once a day for example.

Static website generators will create a complete HTML page based on your content and a given templating system (with probably a theme specified) and once it’s done, no matter how many people visit your site, it won’t be regenerated; not unless you type in a specific command on your computer! They’re solving the commenting “problem” by either not using it at all, or switching to JavaScript based solutions, the most popular being Disqus, but Facebook and Google Plus comments (and others) will work too. I can personally vouch for Disqus, it’s a great system that integrates with WordPress very well, plus I don’t even remember the last time we had to deal with a spam!

There are a couple of WordPress caching plugins that you can use to create static HTML files of your posts and pages, but if you’re using Nginx as your web server (and if you don’t, you really should, but that’s a topic for another article) you can just flip the full page caching switch on and set it to expire in a day or a week. The longer period you can “afford” to set it to, the better. What happens next is that the first visitor will have the server generate the complete, cached HTML files and any consecutive visitors within the predefined expiration period will get served those files.

static_5ms

For comparison, based on our recent tests while a WordPress page with a premium theme and WooCommerce activated will take about 250ms to get fully built and served, you can go as low as 110ms with HHVM, but the same page will be handed over in just 2 to 5ms when it comes from a prebuilt FastCGI cache! That’s a 50x performance improvement, not to mention that it won’t eat up hardware resources, so you’ll be able to handle enormous waves of traffic if it comes to that!

How to set it up, you ask? Well if you manage your own servers here’s an extremely detailed guide by DigitalOcean that you can follow. If you have a shared/managed hosting account, you can ask your support team to set it up for you. And if you’re a Kinsta WordPress Hosting client, you open up a ticket with our support team within your MyKinsta dashboard and request a longer cache duration.

Just please make sure first that you fully understand the consequences of doing so.