borkdude / quickblog

Light-weight static blog engine for Clojure and babashka
https://blog.michielborkent.nl/
MIT License
165 stars 28 forks source link

Add social media sharing preview #23

Closed jmglov closed 2 years ago

jmglov commented 2 years ago

At the moment, sharing a quickblog URL on Facebook, Twitter, LinkedIn, etc results in just the URL. It would be nice if the link was rendered as a "sharing card" with a title, post summary, and preview image. The feature could work like this:

Social sharing

Social media sites such as Facebook, Twitter, LinkedIn, etc. display neat little preview cards when you share a link. These cards are populated from certain <meta> tags (as described in "How to add a social media share card to any website", by Michelle Mannering) and typically contain a title, description / summary, and preview image.

By default, quickblog adds tags for the page title for all pages and descriptions for the following pages:

If you specify a :blog-image URL option, a preview image will be added to the index, archive, tags, and tag pages. The URL should point to an image that is 1200x630 and maximum 5MB in size. It may either be an absolute URL or a URL relative to :blog-root.

For post pages, meta tags will be populated from Description and Image metadata in the document. For example, a post could look like this:

Title: Sharing is caring
Date: 2022-08-16
Tags: demo
Description: quickblog now creates nifty social media sharing cards / previews. Read all about how this works and how you can maximise engagement with your posts!
Image: assets/2022-08-16-sharing-preview.png

You may have already heard the good news: quickblog is more social than ever!
...

The value of the Image field is either an absolute URL or a URL relative to :blog-root. As noted above, images should be 1200x630 and maximum 5MB in size for best results.

Resources for understanding and testing social sharing:

jmglov commented 2 years ago

@borkdude I have a PR ready for this as soon as the testing one is merged. :)

borkdude commented 2 years ago

Sounds good to me.