Social preview images (Open Graph images) are the thumbnails shown when your page is shared on social media or messaging apps. For multilingual websites, a single generic image means every language version shows the same visual, missing a chance to reinforce the local message. This guide shows you how to create dynamic, language-specific preview images using a simple template and a few lines of code, so each share looks native to its audience.
What You’ll Need
- A website with multilingual pages (e.g., /en/, /fr/, /de/).
- Access to your site’s HTML head section or a server-side template.
- An image editing tool (Photoshop, Figma, or a free tool like Canva) to create a base template.
- Basic understanding of HTML meta tags and server-side scripting (PHP, Node.js, or similar) or a static site generator that supports custom meta tags.
Step-by-Step
- Design a base template – Create a 1200×630px image (the standard Open Graph size) with your brand colors, logo, and a blank space for text. Leave the text area empty; you’ll add it dynamically.
- Export the template as a layered file – Save your design in a format that preserves layers (e.g., PSD) or as a transparent PNG if you plan to overlay text with code.
- Set up a dynamic image generator – You have two main options:
- Server-side generation: Use a library like PHP GD, ImageMagick, or Node.js Canvas to render text onto the base image on the fly.
- Client-side generation: Use an HTML canvas and a headless browser (like Puppeteer) to screenshot a styled HTML page as the image.
- Create a route or endpoint – For example,
/og-image?lang=fr&title=Bonjour. This endpoint will take parameters (language, title, etc.) and return the generated image. - Localize the text – For each language, have a mapping of common strings (e.g., site name, tagline). Pass the page title and language code to the generator. If using a translation file, fetch the translated strings server-side.
- Render the text onto the image – Using your chosen tool, draw the localized title and any other text onto the base template. Ensure the text fits within the safe area (typically 100px margins) and use a font that supports special characters (e.g., á, é, ü, Cyrillic, CJK).
- Cache the generated images – Store the output as a file (e.g.,
/images/og/fr-home.png) to avoid regenerating on every request. Set a long cache header. - Add the meta tags to each page – In the head of each localized page, include:
<meta property="og:image" content="https://example.com/og-image?lang=fr&title=Bonjour" /> <meta property="og:image:width" content="1200" /> <meta property="og:image:height" content="630" />
- Test with the sharing debugger – Use Facebook’s Sharing Debugger or Twitter Card Validator to check that the correct image appears for each language URL.
- Automate for static sites – If you use a static site generator, pre-generate all images at build time using a script, then reference the static files.
Common Mistakes
- Using a single image for all languages – This defeats the purpose; always generate per-language images.
- Text overflow – Long titles in German or Finnish may not fit. Always test with the longest possible string.
- Ignoring special characters – Fonts may not support all glyphs. Use a web-safe font like Noto Sans or Arial Unicode.
- Forgetting to set absolute URLs – Open Graph images must be absolute URLs, not relative paths.
- Not caching – Generating images on every request slows down your site and can break under load.
- Wrong image dimensions – Some platforms prefer 1.91:1 ratio; using 1200×630 is standard, but 1200×1200 works for square formats.
Tips
- Use a consistent layout but change the background color per language to create visual distinction.
- Include the language code or a localized label (e.g., “FR” or “Français”) to reinforce the language.
- Keep text concise – aim for 4-6 words for the title, as long text becomes unreadable on small screens.
- Use a CDN to serve the images globally for faster loading.
- For dynamic sites, consider using a service like Cloudinary or imgix that offers on-the-fly text overlay, saving you coding time.
- Always test on multiple platforms (Facebook, Twitter, LinkedIn, WhatsApp) because they render images differently.
Troubleshooting
- Image not appearing on social media – Clear the cache of the sharing debugger. Facebook and Twitter cache aggressively; use their debugger tools to scrape fresh.
- Text is cut off – Reduce the font size or add a text wrapping function. Measure the text width and adjust accordingly.
- Special characters showing as squares – Switch to a font with broader Unicode support, or embed a font that covers the languages you need.
- Image generation is slow – Cache aggressively, or pre-generate at build time. If using server-side, consider using a fast library like Sharp (Node.js) or ImageMagick.
- Different languages show the same image – Check that the URL includes the correct language parameter and that your endpoint reads it correctly. Test the URL directly in a browser.
- Image loads but is blank – Ensure the font file is accessible on the server and that the text color contrasts with the background.
Frequently Asked Questions
Do I need a different image for every page or just per language?
It’s best to have a unique image per page, but at minimum per language. If you have many pages, you can generate them dynamically based on the page title.
Can I use a static image with just the language name?
Yes, but it’s less effective. A generic image with the language name is better than nothing, but including the page title gives more context.
What is the best image size?
For most platforms, 1200×630 pixels (1.91:1 ratio) is optimal. For Twitter, 1200×675 is also fine. Ensure the file size is under 8MB.
How do I handle languages with right-to-left text?
Use a library that supports RTL text rendering, and adjust the text alignment accordingly. Most image libraries have options for text direction.
Can I use a third-party service instead of coding my own?
Yes, services like Cloudinary, imgix, or Vercel OG Image Generation allow you to create dynamic images with less code. They often have built-in localization support.
Will this affect SEO?
Yes, positively. Social preview images can increase click-through rates, and having localized images can improve user engagement, which indirectly benefits SEO.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- Server Repair Fails: Fix Restart Loops
- Plane Crazy Summer Event Schedule & Dates3 tier
- How to Choose a Secure IMAP Email Client
- Tower Defense RNG Codes: Active List & How to Redeem
- RCS Chats On or Off in Google Messages
- How to Choose a Phone That Supports VoLTE on Your Carrier