WordPress static hosting with firebase and google cloud

Some time ago i started looking to move this wordpress blog into a static file blog system. So to find the best tool a started to test the different blog tools like jekyll and hugo.

They all worked good but a found it hard to edit my blogs in static files and also to generate and then deploy the site. Its hard to move away from wordpress when you have started. So then gave up the work on moving to a static file blog.

But during the latest time i have started to work more and more on firebase and cloud functions on the google cloud platform.
So then i started to again think about moving wordpress to a static file hosting and this time i got it to work !

WordPress, Firebase rendering at request

The first approtch was to use the wordpress API and fetch all the post and pages. I then saved the json from the api into the firebase database.
Then a added a small request webbserver and then a got a request to /blog/name i could query the firebase database for the post then render the json trow a teplate and return the html to the client.

This work well for https://hacking.robots.beer that i have setup to use this way. But the speed for getting the pages are slow and its not really any better then my wordpress I had (will its less request ).

WordPress, Firebase render to bucket

To get the speed a wanted then a need to render tha pages as one as store them into a bucket. Now in firebase you can access the hosting bucket (Dont now why) so i need to use a other bucket and a Google Loadbalanser to get the the traffic to my page.
So for this i hade to first create a cloud fucntions that connected to the wordpress api and got all the post and pages. Then run them trow my templating to get html pages.
The html pages where then uploaded to a google cloud bucket.
And the result is the blog you are reading now.

To upload the media i use the wp-stateless plugin in wordpress that are connected to the same bucket.

The code

Here is a link to the code i use https://github.com/mattiashem/wordpress-firebase This is the raw and i will work some more to have the code render multiple sites to different buckets and also clean up the code 🙂