Last updated: Sep-12-2024
Overview
This video tutorial teaches you how to create dynamic social media cards using the CldOgImage component from the Svelte community-developed library in your existing Svelte application.
Video tutorial
Tutorial contents
This tutorial presents the following topics. Click a timestamp to jump to that part of the video.
Introduction
0:00 | Social cards are a great tool for increasing engagement on a link shared on a social media platform. However, they can be challenging to create and configure in your Svelte application, especially when you want to make these cards dynamic. The Svelte community-developed library simplifies this process, and in this tutorial, you'll see how to use this SDK to create dynamic social cards for a blog website. |
Importance of social cards
0:22 | Social cards display text and images for a page when the link is shared on social media platforms. The more eye-catching these cards are or the more context they provide, the more they can entice your audience to click such links. You can configure the text and images on these cards using OG tags and X (Twitter)-specific tags. It has become crucial to add text directly to your images for X cards because titles have been removed from social cards on X, which also removes important context for your visitors. |
Using CldOgImage
component
0:55 | You can easily configure these cards using the CldOgImage component from the Svelte community-developed library in your existing Svelte application. Ensure you have Svelte and Cloudinary installed and set up. For a blog website, import the CldOgImage component from the Svelte community-developed library and use it by passing the public ID of your image to the src prop. You can use the OGraph Previewer extension to check the social card for different blog posts. |
X (Twitter) props
1:33 | You also have to pass the alt and twitterTitle props for the titles that appear on the social cards. |
Adding context with overlays
1:38 | You can add more context to your cards using the effects and overlays provided by Cloudinary. For example, you can overlay the title text on your image. By using effects like blur and text overlays with dynamic content such as post.title , you can create visually appealing and contextually relevant titles based on the specific blog post title. |
Advanced configurations - two overlays
2:03 | For more advanced configurations, you can add multiple overlays, including an overlay for the image title and tagline. This setup allows for a more comprehensive and visually appealing social card. By previewing these configurations, you can ensure that your social cards are dynamic and informative, increasing the likelihood of engagement when shared on social media platforms like X (Twitter). |
Advanced configurations - three overlays
2:37 | Here's the configuration for adding multiple overlays, including an overlay for the image name, the title, and the tagline. |
Keep learning
- Visit the Svelte community-developed library documentation to learn more about the Svelte-Cloudinary components, including their configuration, usage and examples.
- Check out the Transformation reference for a listing of all Cloudinary transformations, including syntax details and examples.
- Discover all the community-developed libraries that Cloudinary has to offer.
- Watch more Dev Hints videos on the Cloudinary YouTube channel.
If you like this, you might also like...
Upload Assets in SvelteKit
Upload assets using the Upload widget in a SvelteKit appGravity Crops for Images
Indicate which areas to keep when croppingOptimization Tips
Tips for delivering optimized images
Check out the Cloudinary Academy for free self-paced Cloudinary courses on a variety of developer or DAM topics, or register for formal instructor-led courses, either virtual or on-site.