A step-by-step guide to convert WordPress (WP) into a static site and host them in Google Cloud Storage (GCS).
Running massive traffic WordPress site is challenging. There are many factors:
- Expensive – require server(s) based on size of traffic
- Skills – you must be skilled in optimizing web server, database, PHP, WP for optimal performance
- Security – have to ensure necessary WP related security is implemented to avoid being hacked
- Maintenance – you need to regularly updated WP core, themes, plugins to ensure doesn’t expose any vulnerability or break because of compatibility issue
A static site is lightweight and security is less concern.
You can get the static site running on cloud storage like GCS and pay for just storage/bandwidth cost (much lower compare to WordPress server).
I know what you are thinking.
Making site with WordPress is easy as it got large themes and plugins marketplace. You can make your site ready with WP in just a few minutes/hours which will take longer to design/develop using static HTML/CSS/JS.
So how do you not leave WordPress and enjoy static site benefits, together?
The idea is to use WordPress to build your site and once done, convert them into static HTML files.
Let’s see how to do it efficiently.
Exporting WordPress to Static HTML Files
There are many ways to achieve this, but I found the following procedure is straightforward. As usual, try in staging/non-prod environment first to see how it works.
- Login to your WordPress Admin
Note: if you don’t have WP setup yet, then you may setup LAMP environment on your local PC or use shared hosting like SiteGround.
- Go to Plugins >> Add new
- Search for “Simply Static” and install >>activate
- On left navigation, go to Simply Static >> Settings
In most cases, you can leave all settings default but take a look and see if you need to include or exclude any URL manually.
- Go to Generate and click “Generate Static Files.”
It will take some time based on a size of your site. I am testing with some dummy installation which got 56 URL and took 5 seconds.
- Download the zip file by clicking “Click here to download.”
This concludes WordPress site is converted into static files and it’s time to put them in Cloud Storage.
Updates: I came across another two solutions which help to make WordPress site static too.
- HardyPress – provide an option to convert existing or create a new site. It provides hosting as well.
- Shifter – Serverless WordPress hosting.
Hosting WordPress Static Files to Google Cloud Storage
I got one spare URL (techpostal.com) which I will be using for this demonstration.
First thing, you got to verify the domain ownership with Google.
- Go to Google Cloud >> Storage (direct link)
- Click create bucket
- Enter bucket information and storage class and create
- Go back to the browser
- Select the drop-down next to newly created bucket and select “Edit website configuration.”
- Enter main page –
- Select the drop-down again and go to “Edit bucket permissions.”
- Enter allUsers in add members >> select role as Storage Object Viewer and click Add
- Go back to the browser and upload the extracted zip file which you downloaded in previous steps
Next, you need to update your domain record to point to cloud storage
- Login to your Domain registrar panel and update CNAME record of your domain to c.storage.googleapis.com
- Wait for few minutes and check DNS record to ensure it’s resolving to the configured one
and finally, let’s access the URL
So as you can see, it works.
BTW, if you want to implement SSL, then you can refer this guide.
There are few limitations to be aware. The static site won’t be able to do certain things like WordPress.
- Comments submission
- Opt-in forms
So if you heavily rely on those then this may not be a good solution, however, if you are using WordPress site as an information page, startup, personal then it’s worth giving a try.
What do you think about it?