Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ feat: add support for social media cards #130

Merged
merged 8 commits into from
Sep 6, 2023
Merged

Conversation

welpo
Copy link
Owner

@welpo welpo commented Sep 6, 2023

Summary

This PR introduces a new social_media_card setting so that links shared on social media sites have an image preview. Like this:

with_social_media_card

Changes

  1. New social_media_card Setting:

    • Can be configured in config.toml, section front matter, and page front matter.
    • Hierarchy for setting value: page > section > config.
  2. Cache Busting:

    • Cache busting implemented for social_media_card URLs to ensure social media sites fetch the latest image.
  3. Social Media Cards Added:

    • Social media card images added to all posts and sections in the theme.
  4. Documentation Updates:

    • Updated config.toml and theme.toml documentation with comments explaining the new social_media_card setting.
  5. HTML Tag Fixes:

    • Corrected some HTML tags related to social media to ensure proper rendering.
  6. Macro Updates:

    • Modified the hierarchy macro to handle non-boolean values, such as the new social_media_card setting.

How to automate the creation of social media cards

I created all the cards running one command. For those interested in how I automated the creation of the social media card images, check out my blog post: From Bashful to Social Butterfly: Automating Link Previews for Zola Sites. There I explain how I created the script I used to create these images (and automate their creation).


Example

Here's one of the automatically generated social media cards, which will be shown as a preview when the post is shared on social media (Telegram, LinkedIn, Mastodon, Twitter…):

blog_security

@welpo welpo added the enhancement New feature or request label Sep 6, 2023
@welpo welpo marked this pull request as ready for review September 6, 2023 01:10
@welpo welpo merged commit d53b847 into main Sep 6, 2023
1 check passed
@welpo welpo deleted the feat/social-media-cards branch September 6, 2023 11:38
welpo added a commit that referenced this pull request Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant