WordPress as a static website generator?

WordPress is a great blogging platform. It’s easy to create content and has a good ecosystem of plugins and themes to extend your website. But it has a few problems that have kept me from using it for personal projects:

  • security – WordPress security has improved a good deal over the past few years but there are still core security issues being exploited yearly. With auto-updates, the risk is minimized but it’s still there. Plugins exist to better secure WordPress, but core issues can never be completely protected via plugins. WordPress installations can’t be neglected for this reason.
  • performance – WordPress out of the box isn’t very fast and chews up memory. Again, there are plugins of various quality with cumbersome installation steps that may mitigate these issues. There are server side caching solutions as well, but for a personal website why bother?

When it comes down to it, most personal blogs are just serving HTML content with little need for the dynamic abilities that PHP gives to WordPress.

What about WordPress.com? The cost is certainly reasonable, but the arbitrary limitations on what can be customized and enabled just doesn’t seem right.

But what if we think about WordPress as a static website generator? When WordPress is first installed, the only dynamic functionality that is enabled besides the admin dashboard is commenting and search (and XML-RPC and REST…). If you don’t need that functionality or can find alternative services, using WordPress as a static website generator is relatively straightforward.

First you have WordPress installed somewhere. If you still want to be able to create and edit content via the web, then you can install it as usual but limit access to it at the web server layer (Apache, NGINX) by enforcing basic authentication or some other mechanism. There are many ways this could be done, with firewalls, Docker, etc. the possibilities are endless. Otherwise you can just install it on a computer at home.

Disable comments and search, unless you have alternatives in place like Disqus or Google Custom Search Engine. Configure WordPress like usual and start creating content! Use a tool like HTTrack to create a static mirror of your website and upload the HTML somewhere!

Of course the last few steps have a few details you’ll need to work through but they can be automated so that you can update your website quickly. With static HTML, you can use Amazon S3, Github pagesGitLab Pages, Dropbox, or a simple static HTTP server to host the content with less risk than a wide open WordPress install with better performance and it can be for free or very cheap.

As I work through hosting my own blog in this fashion, I will try to share tips and code to make WordPress as a static website generator as easy as it is sensible. I think many brochureware marketing sites and blogs that are built with WordPress could ultimately be static websites.

Finally, what about traditional static website generators like hugo? They are certainly the answer if: you don’t need native web access for content updates and are able to customize a theme or use one of the more limited number of ones that are open source.