Hacker News new | ask | show | jobs
by cmroanirgo 2841 days ago
> What do you mean by adding images?

For me, lack of nice (ie. controllable, but 'automagic') image handling is a huge bug bear in nearly every cms out there, static or otherwise. Perhaps I didn't find the right platform/plugin...

In my case, I wanted to have 1 source image that was resized at various (author controllable) sizes and then saved them, while also generating supporting HTML (eg. 'srcset' to automatically swap between them). I ended up with a couple of ways to template it in [0]:

For a thumbnail:

<img src="{{image #thumb{w:50} }}">

For srcset:

<img src="{{image}}" srcset="{{image #srcset{w:'256,512,800',orig:'1152'} }}" sizes=...>

[0] https://github.com/ergo-cms/plugin-thumbnail. (Note the entire project itself stalled some time ago, and wouldn't recommend it here -- even though I do dogfood it)

EDIT: reorder wording

2 comments

I think this is a task that is handled by an optional CMS, not the static site generator itself, though I agree it would be handy to have a little helper snippet to do that during build.

There are CMS solutions for static sites which will probably handle images, and all kinds of content, easily. Check out Dato[1], Siteleaf[2] or Netlify CMS[3].

Alternatively you can use external tools to prepare your images and simply rely on the standard HTML srcset within your static site generator of choice. I use RetroBatch[4] to prepare my images.

[1] https://www.datocms.com/

[2] https://www.siteleaf.com

[3] https://www.netlifycms.org/

[4] https://flyingmeat.com/retrobatch/

I see, so image resizing on build. I like the idea.

That should be doable. I may consider implementing something like that in my own SSG some day.