WordPress static content generator

Lately, I’ve been really interested in generating static content. Most websites out there are based on a CMS, WordPress going for 20% of all known websites, reason why I decided that would be useful to have a WordPress static content generator. There are a lot of solutions out there for generating static content and some have an option of importing your WordPress content, but I wanted to see how this can be done.

I’ve set up a VM running a webserver and WordPress. To skip the hasle of configuration, you can use something already made from Turnkey.

wpStaticGenerator-concept

Description

  • on the laptop there is VM running WordPress – it can be accessed via IP address or hostname in the users browser
  • the VM cannot be accessed from the internet but it can access the internet through the host (host-only network)
  • in the WordPress admin interface the user has a plugin which he can use create a static copy of the website (Really-Static)
  • there is another plugin for the WordPress static generating script, where the user can access to parse the contents of the static files and upload them to the host provider

wpStaticGenerator-activity

The bash script (staticWPtoGH.sh) is where all the parsing and uploading happening.  The WordPress static generator plugin is PHP interacting with the bash script, providing an easy way for the user to run the script without CLI access. I opted for bash as I wanted a fast and working way to do this, in an automated fashion on the command-line. Later, I saw the need for WordPress to interact with it easily, having the WordPress plugin too. The code can be found on my github.

Currently, the code is a bit messy and variables in the script cannot be changed from WordPress. An ideal situation will have the bash script converted to PHP and integrated with Really-Static to have a single plugin covering all functionality. Really static is not being updated for over 1 year, the code is messy and it has German comments – but it works like a charm! Reason why I chose it over the other alternatives.

At the moment of writing, this blog is being served as static files generated from a VM on my PC. I’m using Disqus for comments, so comment functionality hasn’t been lost.

Challenges to consider

1. Making this as accessible as possible to the non-tech.

Right now I’m talking virtualization, bash, command-line. That’s clearly a no go for non-techs, reason why I’m seeing the ideal situation as written above, where everything is happening from the WordPress admin interface.

2. Is it really needed to be made accessible to non-techs ?

It all depends on the goals and scope for the project. My initial goal was to have a fast way to generating static content of my WordPress blog without the need to use a different platform. A following goal might be that of making this available for all non-techs. Or maybe just for web development companies.

Have any suggestions on how you’re seeing this used ? Leave a comment with that, or e-mail me.

On the same topic

  • vishal

    What about contact page having form?

  • Hi Victor, liked the solution.
    I only have one doubt, what about content generated by plugins like WP Download Manager (a document management plugin), of course some resources like tracking how many times a file was downloaded won’t work, but how can a situation like this be tackled?