RT Cunningham

WordPress Static Site Generator, Part 1 – Introduction

This my second attempt to describe the WordPress static site generator I’ve developed over time. I removed the articles describing my first attempt months ago.

The idea is to develop your website using web development tools on your home computer. You use scripts and other software to turn the pages and posts into static pages and then upload them to your online web server.

Why a WordPress Static Site Generator?

I hosted my website using WordPress the normal way for years. I started developing the WordPress static site generator when I got tired of the brute force login attacks and the constant barrage of comment spam. Although I solved all those problems eventually, I continued to develop it.

I no longer need to host a database server. I don’t even need PHP to process forms. With static pages, there’s nothing left to attack. I can ignore my website for days without having to worry about someone hacking into it. The best thing about all this is that static websites can be hosted anywhere.

Static websites are static, obviously. Most dynamic features can’t be converted to static. If you need dynamic features, especially for display, a static website is not your best option.

Software for your WordPress Static Site Generator

While I’m using the Linux Mint operating system on my home computer, you’re probably using something else. If you’re using Linux, it’s best to install Apache or Nginx, PHP and MySQL (or a compatible replacement) just like you would on a server. Otherwise, you should use a LAMP or LEMP stack designed for your operating system.

You need a good text editor. I like Geany for Linux and Notepad++ on Windows. You may or may not need an FTP client and you may or may not need an SSH client. It depends on how you intend to transfer files to the online web server. I like FileZilla as my FTP client and I like PuTTY as my SSH client. There are other ways to transfer files that I’m not familiar with.

Once you have your local web server running, you need to install WordPress and set it up properly. Get a theme you like and make sure there’s nothing dynamic going on with it.

WordPress Static Site Generator PHP Scripts

You need two scripts. The first is “functions.php”, which is usually one of the files in your theme. The second is a PHP file you can name anything before the “.php”. If a functions file already exists and it’s being used, you’ll have to add the necessary functions to it.

The second script is the WordPress static site generator itself. You can’t do anything without this script, which you’ll keep with your theme files. It loads WordPress, queries the database and saves the pages and posts as complete static pages.

Upcoming Articles

I’ll be writing articles to set everything up, step by step, from beginning to end. Some of the information may seem simple and some of it may seem complex. I’ll be trying to keep it simple.


April 19, 2018
Web Development

You May Also Like: