New blogging platform

Lee Hawthorn November 11, 2023 #Info

Some of you may know I was previously running this blog using Gatsby JS. I've been looking for a simplified static hosting system for a while as Gatsby uses lots of NPM dependencies.

As I'm a huge fan of using Markdown to write content, my primary goal in searching for a platform was for it to have as few dependencies as possible and less moving parts. I enjoyed learning GraphQL with Gatsby, however, I don't really need that complexity.

I came across Zola by accident. Zola is a Rust based static site generator with a single binary. This appeared right up my street. I'm not bothered by the speed, but I can tell you it is really fast. On Gatsby this blog took minutes to build, on Zola it takes 283ms on dev.

Zola build speed

My build environment is WSL running on Windows for dev/deployment purposes. I understand Zola is Windows compatible.

I've been very happy with the Netlify service, so I'm still using Netlify to host it as they make it really simple to set up. All I needed to do was change the repo in the Netlify portal.

The build on Netlify is completed in much faster time, although, this wasn't a priority for me.

Netlify build speed

Now I didn't have time to create CSS, so I used a template from Abridged

This was fully integrated with Zola. It uses a few NPM dependencies but compared to Gatsby this is a drop in the ocean. One is able to select not to use JS too. I left it on as I wanted to use the Search feature as well as include a label on code comments to allow easy copying.

I wanted to optimise my images as that was something Gatsby did for me. The author of the Abridged platform was helpful here with the documentation they provided.

Slight issue I had was related to having my markdown files with images in separate folders from Gatsby days.

The tool I used is called oxipng

To get this running on WSL I had to manually build it. Oh well, that was the first Rust app I've had to build. This was quite simple using CRATE.

I didn't want to manually run the command in each folder, so I used the GNU Linux Find command.

After running the command below in the content folder it found all the images and piped them into oxipng.

find . -name "*.png" -exec oxipng -o  max --strip all -a -Z {} \;

This did take a few hours to get through the images. I managed to reduce size of images by 25-50% though, so it was worth it.

I ran into a slight issue after publishing - I had entered my url in the Zola config as leehbi.com but on deploy that gets redirected to www.leehbi.com.

This leads to CSP errors as the CSS/JS was coming from a different domain. CSP in browsers works well when it works - it can be tricky for enablers.

All I needed to do was put the URL in the Zola config.toml as www.leehbi.com

In Netlify, I had to select Deploy with Cache clear as I needed the JS to rerun.

For those interested, I have the Zola folder in GitHub and I set up Netlify to re-deploy on every push, straight from Master.

That means all I need to do is a git push in VS Code and my published blog will be updated a few seconds later.

If you are running a commercial operation you can use Branching and Pull requests and I should say Netlify has a preview deploy if you want to use it. I go direct to production as that suits me.

I'm writing this post after putting new blog into production so will see how it goes from here.