I built a Hugo module which generates srcsets

I built this module which generates automatic srcsets for your Markdown images: https://github.com/jan-xyz/hugo-module-img-srcset

All you need to do to get source sets now is:

In your hugo project run

hugo mod get -u github.com/jan-xyz/hugo-module-img-srcset

and add the module to your config.toml :

...
theme = [ "github.com/jan-xyz/hugo-module-img-srcset"]
...

I hope this helps someone :slight_smile: I was looking for something like this for quite a while and was actually pointed by @bep into the correct direction today: https://github.com/gohugoio/hugo/issues/5034#issuecomment-706602779

8 Likes

Nice.

In your installation instructions, the first step (hugo mod get -u) should not be needed. Adding it to your config.toml should be enough.

2 Likes

Very cool! :1st_place_medal:

1 Like

@bep thanks, I didn’t know that! I removed it from the README.

A fix was just released: if you previously tested this module and couldn’t make it work, give it another try: a fix was released a few days ago.

Thanks @janxyz for this awesome module!

hi @janxyz

I already use a partial which generates multiple image sizes, convert jpg to webp and also serve the 2x images. Is using the module you create better then using a regular partial layout for image? if yes how?

thanks