quarkusio.github.io icon indicating copy to clipboard operation
quarkusio.github.io copied to clipboard

Generate social images

Open gastaldi opened this issue 2 years ago • 17 comments

  • Fixes https://github.com/quarkusio/quarkusio.github.io/issues/1723

gastaldi avatar Jun 14 '23 19:06 gastaldi

😭 Deploy PR Preview failed.

github-actions[bot] avatar Jun 14 '23 23:06 github-actions[bot]

Marking as a draft since the images generated in _site/assets/images/social are being deleted during the build

gastaldi avatar Jun 14 '23 23:06 gastaldi

yeah jekyll needs to know about the images - you can't just dump them into directories that comes from direct copies.

I had this issue in the past - trying to recall what was the fix...

maxandersen avatar Jun 15 '23 08:06 maxandersen

so yeah, now i recall - you need to have it be a full plugin OR commit them to the actual repo.

Did you try see if https://github.com/boyvanamstel/jekyll-gensocial might just work?

maxandersen avatar Jun 15 '23 08:06 maxandersen

actually gen-scoial could be useful for the blog style content. maybe https://github.com/jekyll/jekyll-seo-tag in combination would be good?

for ascidoc might just steal the approach of gen-social to generate into the source dir that could be in a git ignored folder?

maxandersen avatar Jun 15 '23 08:06 maxandersen

I've given https://github.com/boyvanamstel/jekyll-gensocial a try and here are my impressions:

Pros

  • It works for blog posts
  • It lets you override the default settings per blog post (https://github.com/boyvanamstel/jekyll-gensocial#overrides)

Cons

  • It only works for blog posts (Under _posts)
  • You MUST have an image: attribute in the blog post otherwise nothing happens
  • Files are generated inside assets/images, changing your source tree (that's why the generated images are not deleted during the build)
  • The generated text isn't center-aligned

In case you're curious, I've pushed a working configuration in https://github.com/gastaldi/quarkusio.github.io/tree/jekyll_gensocial

gastaldi avatar Jun 15 '23 14:06 gastaldi

@gastaldi what's the status of this?

gsmet avatar Jul 21 '23 14:07 gsmet

It works, but the generated files' sizes surpass the maximum allowed upload size in surge.sh

gastaldi avatar Jul 21 '23 14:07 gastaldi

This might help: https://github.com/marketplace/actions/imagemagick-action. I've used ImageMagick in the past to resize images. In that case they were pictures of fish I was batch-processing, but the principle would be similar.

... or we could do the equivalent in code, maybe with this: https://github.com/rmagick/rmagick. That would have the advantage of being the same locally and in GitHub ... and the disadvantage that ImageMagick has some native components, so the install might be a bit fiddly. Or it might not be - I haven't tried it via a gem.

holly-cummins avatar Jul 21 '23 17:07 holly-cummins

@gsmet according to your suggestion, I added a config that skips the social image generation during preview and it seems to work.

gastaldi avatar Oct 10 '23 14:10 gastaldi

boy this is slow locally ...how long does it take you to build?

maxandersen avatar Oct 24 '23 13:10 maxandersen

The first build is slow indeed. The subsequent ones are faster

gastaldi avatar Oct 24 '23 13:10 gastaldi

I run this locally and it generates social images but I only see "quarkus_card.png" in og:image of blogs is that expected?

maxandersen avatar Oct 24 '23 14:10 maxandersen

I run this locally and it generates social images but I only see "quarkus_card.png" in og:image of blogs is that expected?

Yes, because I am only generating social images for guides. See https://github.com/quarkusio/quarkusio.github.io/pull/1725/files#diff-41b71bd8e56b7f1670ccca46cbf0dec0b906a961b0a9c140914425009ecc879aR36 and https://github.com/quarkusio/quarkusio.github.io/pull/1725/files#diff-41b71bd8e56b7f1670ccca46cbf0dec0b906a961b0a9c140914425009ecc879aR11

gastaldi avatar Oct 24 '23 14:10 gastaldi

mkay - but aren't the blog posts the most shared ones for social images?

why only guides?

maxandersen avatar Oct 24 '23 15:10 maxandersen

So far I have only shared guides in my chat messaging apps (which is why I made this change). That may work, need to improve the script to read from the blog directory too.

gastaldi avatar Oct 24 '23 15:10 gastaldi

@gastaldi fun - i rarely share guides - its more blog posts :)

maxandersen avatar Oct 31 '23 10:10 maxandersen