Can Hugo generate only webp images and skip jpg?

I checked the resources folder and there are a lot of resized jpg images. I use webp entirely on my site and all resized images are in webp with no fallback. Is there a way to prevent generation of these jpg images?

If you’re using .Resize or .Process, then you can specify the target format as part of the call to those methods

1 Like

Is this a problem?

I already do that. Using the Fill method with .Process.

Not a ‘problem’ per se. But if it is possible not to generate these images, then I would prefer that.

They represent cached steps in the imaging pipeline. Don’t worry about it.

Are they counted in the total of Processed images? Coz I remember you saying the total shown is faulty. (I am trying to diagnose templates build time).

If you have 6 images in the assets directory and do this:

{{ range resources.ByType "image" }}
  {{ with .Resize "200x png" }}
    {{ with .Resize "150x webp" }}
      <img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
    {{ end }}
  {{ end }}
{{ end }}

The number of processed images displayed in the build stats will be 12 because you have processed 12 images.

I checked my image processor code in partials and I saw there was a redundant resize generating jpg images. Removed it and purged the resources folder and now everything works as expected.

1 Like

I actually checked and I only generate 6 images per page (for the cover image, as this specific site is text-heavy) in 3 partials. So, the processed images count might be in line with what Hugo shows.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.