Hosting a blog as pure HTML only

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 costs to run Tweaked for your Pleasure.

With this in mind, I am going to 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.
  • I must use WordPress for adding new posts from my end.
  • Guests MUST be able to post a comment.

Picking the free host

The main goal is 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’s 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.

Having thought about this for a while I remembered what I did for snat.co.il and used Disqus and its Javascript option. When I had a Hebrew version of Tweaked for your Pleasure I used the same installation for both and in the comment file I simply put an IF statement that checked if the URL was snat.co.il and if so it used the Javascript option and it worked very well.

For those wondering the code I used for snat.co.uk and snat.co.il was.

<php
$WhichLanguage = $_SERVER['HTTP_HOST'];
if ($WhichLanguage == "snat.co.uk" ) 
 {
    Disqus Embed Javascript for co.uk w/ permalink.
 } 
if ($WhichLanguage == "snat.co.il" ) 
 {
    Disqus Embed Javascript for co.il w/ permalink.
 }
?>

I replaced the comment code with the embedded Javascript code and behold the comments worked and they updated in real time. The reason for this is the comments were simple Javascript-embedded code that works on any web browser – no PHP needed. It did mean I could not have a local copy of the comments but it would be a good trade.

The Result

Did it work, was it worth it and would I do it? To answer the first part 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 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 being able to tailor this for users such as the Honeygain banner which only shows for certain countries – something I can’t 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 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 reference?

Ellis, M. (2021). Hosting a blog as pure HTML only. [online] Snat's Narratives & Tales. Available at: https://snat.co.uk/stem/scripts/an-experiment-hosting-a-blog-as-pure-html-only.html [Accessed 06 Oct 2024].

Thanks for reading! You may be interested in this …

Join the Discussion

Learn how to host a WordPress website for free without relying on PHP or MySQL using GitHub and static HTML files, and find out if it's worth the effort.

1 thought on “Hosting a blog as pure HTML only”

  1. I have looked into this a bit further as I am tempted to still do this but there is a plugin known as Simply Static. Another thing I have learnt is Cloudflare offers something called “Cloudflare Pages“.

    The only thing I am wondering is how many images you can upload to Cloudflare Pages as I would be tempted in moving Life in Eorzea over to it.

    Reply

Add to the discussion!

This site uses Akismet to reduce spam. Learn how your comment data is processed.