Writing on Tweaked for your Pleasure is something I have always enjoyed doing and I feel it is something I will be updating for many years to come but one thing I do hate is how much it actually cost to run Tweaked for your Pleasure.
With this in mind, I am going to do an experiment – I want to host this website purely for free and while I could toss this onto most free hosts with PHP I decided to set myself a couple of goals for it to be successful.
- It has to run on ANY free web that allows FTP uploading or something like it.
- It does not have to rely on PHP or MySQL.
- It must use WordPress for adding new posts from my end.
- Guests MUST be able to post a comment.
Picking the free host
With the main goal being to host pure HTML files with no PHP on the actual server that is serving the website as one of the main goals is to be able to host this on many different web hosts to keep it online for redundancy sake, I decided the first host would be to use Github with a custom domain.
Github allows syncing files easily and I can host static pages using a domain – so I can easily host snat.co.uk on there but any free hosting that allows FTP would work fine.
Doesn’t have to rely on PHP
This part is now the tricky bit as the host itself can not use PHP but I can keep it hosted locally and it got me thinking about an idea. The idea is to install WordPress locally as a normal installation and install a caching plugin such as W3 Cache and here is the reason why:
If you got a careful eye you may notice that the caching copies the file structure perfectly (it has to for caching purposes as they are just static files) and that everything you see in cache/page_enchanced is an exact copy of what you would see in a web browser. By this logic all I would need to do is sync this folder and the site would load as normal as long as every page is cached.
In practice it did not work like this but I decided to keep trying a method like this and WP Super Cache seemed to work fine for me. In the end I was able to sync a cached version and upload it to Github. I was able to make new posts locally, re-run the whole caching and then commit all the new files to Github and while it worked it did suck big time and I think I would need to find a new method to do this.
Guests must be able to comment
While I can host the static HTML files in a long and annoying way, I am having an issue with the comments. The issue is using WordPress’s default comments the guest is unable to post a comment as it won’t go anywhere and nor would the new comments show until the cached version is updated.
For those wondering the code I used for snat.co.uk and snat.co.il was.
Did it work, was it worth it and would I do it? To answer the first part is yes, it did work. I was able to make a static version of Tweaked for your Pleasure using caching plugins and uploading it. If I was to actually do it full time I would make a WordPress plugin that automatically exported everything for me in the correct format and a quick search shows there is a plugin for this that works manually: Export WP Page to Static HTML. I would also not recommend Github due to having to keep it all public but this method would work with any host that allows you to upload HTML files but it did work with Github.
Was it worth it? Honestly, I don’t think it is worth it that much but for a different reason. It was easy to get the files themselves onto Github and set up an A record on my DNS and it would also be easy to sign up for a few free hosts and set up a round-robin DNS while also making a bash script to upload the exported HTML files to each FTP server for those free hosts. The reason I don’t feel it is worth it is I lose the flexibility of adding new stuff and to be able to tailor this for users such as the Honeygain banner which only shows for certain countries – something I can’t really do with static HTML pages.
Based on the above it isn’t something I won’t do on this website but there are others I am thinking about but ultimately for the effort above it would save me over £90 a year it cost to host Tweaked for your Pleasure – something that would be worth it if I didn’t have to host any other websites.
Need to quote me?
Ellis, M (2021) An experiment: Hosting a blog as pure HTML only. [online] Tweaked for your Pleasure. Available at: https://snat.co.uk/scripts/an-experiment-hosting-a-blog-as-pure-html-only.html [Accessed 17 Sep 2021]