Switching to WebP file extension in RelPermalink

Hi guys.
Im following https://dev.to/stereobooster/responsive-images-for-hugo-dn9 to add srcset for my images. While trying to get a better google score (i know i know, but it makes me smile) im running into WebP.

Looking around the forum/github/docs ive seen Hugo does not support WebP yet. Ok. I can generate webp images through the command line.
However… how can i populate a webp list with the same images just with a different filename?


If your template already works with jpg-srcsets then check the functions around that. It’s quite probable that the file gets loaded. If that’s the case then you have access to File Variables. Use .File.BaseFileName with a webp ending. For that, the base name of the files, of course, need to be identical and the files need to be next to each other in the folder.

i am getting the file through {{ $src := .Page.Resources.GetMatch (printf "*%s*" (.Get "src")) }}
then passing it through

{{ if ge $src.Width "640" }}
  {{ with $tiny.RelPermalink }}{{.}} 640w{{ end }}
{{ end }}

i imagine i should, then, repeat the src declaration before each .webp and .jpg calls.
Something like:

{{ $src := .Page.Resources.GetMatch (printf "*%s*" (replace (.Get "src") (path.Ext (.Get "src")) ".webp")) }}
{{ $src := .Page.Resources.GetMatch (printf "*%s*" (replace (.Get "src") (path.Ext (.Get "src")) ".jpg")) }}

oh damn, im evaluating the size inside the shortcode if ge $src.Width "640" so now i get an error because, correctly, i dont have the .webp file yet *and* hugo doesnt handle .webp anyway…
now i gotta find a way to output the images without handling them…