HUGO

Optimizing images before publishing

I have been using hugo for a while and wanted to give a little bit back to the community :slight_smile:

As most of your probably know, unoptimized images on website are one of the biggest low hanging fruit to fix when it comes to performance on the web.

Since I have many large images on my blog I wrote a small script that will optimize images after the website is built by hugo. This means that the original pictures in your static/images folder will be left untouched and only the ones in the public/images folder are optimized.

It currently works for PNG and JPEG and will limit the width of pictures to 1400px.

You can find the script at https://github.com/b-m-f/hugo-picture-optimization .

3 Likes

Neat script, especially if added to ones deploy workflow so run automatically.

Hugo can also do some of these things with the recent Image Processing feature.

1 Like

Oh yeah, thats how I have it set up. Instead of executing hugo I now just run the script and then deploy.

And the included image processing looks nice indeed, just didnt fit the use case of having a lot of pictures in blog posts for me :slight_smile:

All image optimization options in hugo are not optimal

изображение

Here is an example of -21% size, although I installed q90 there