Tutorial: Setting Up Open Graph and Twitter Card Meta Tags
This tutorial walks you through implementing Open Graph and Twitter Card meta tags on your website to control how your content appears when shared on social media platforms.
Step 1: Understand the Tag Structure
Open Graph tags use the og: prefix and go in your HTML head section. Twitter Card tags use the twitter: prefix and also go in the head. Both sets of tags should be present on every page you want to be shareable with proper previews.
Step 2: Add Basic Open Graph Tags
Add these required Open Graph tags to every page: og:title for the page title. og:description for the page description. og:image for the preview image URL. og:url for the canonical page URL. og:type for content type typically website or article. og:site_name for your website name. Example: meta property=og:title content=Your Page Title.
Step 3: Add Article-Specific Tags
For blog posts and articles add these additional tags: article:published_time for the publication date. article:modified_time for the last modification date. article:author for the author name. article:section for the content category. article:tag for relevant keywords. These tags help Facebook and other platforms categorize and display your content.
Step 4: Add Twitter Card Tags
Add these Twitter-specific tags: twitter:card set to summary or summary_large_image. twitter:site for your site Twitter handle. twitter:title for the page title. twitter:description for the page description. twitter:image for the preview image. twitter:creator for the author Twitter handle. Use summary_large_image for pages with high-quality images.
Step 5: Optimize Your Preview Image
Create social sharing images that look great in previews. Use 1200x630 pixels for Open Graph images. Use 1024x512 pixels for Twitter summary images. Keep file size under 5MB. Use JPEG or PNG format. Include text overlays with the page title or key message. Ensure text is readable at small sizes. Use contrasting colors that stand out in social feeds. Create unique images for important pages.
Step 6: Implement in Your CMS
Most CMS platforms have plugins or built-in support for social meta tags. WordPress: Use Yoast SEO or Rank Math which automatically generate Open Graph and Twitter Card tags. Shopify: Use SEO apps that add social meta tags to product and collection pages. Custom sites: Dynamically generate meta tags from your page data and content management system.
Step 7: Test Your Implementation
Use these tools to verify your meta tags: Facebook Sharing Debugger to test Open Graph tags and clear the cache. Twitter Card Validator to test Twitter Card appearance. LinkedIn Post Inspector for LinkedIn previews. Check that all required tags are present. Verify images load correctly. Ensure titles and descriptions display properly without truncation.
Step 8: Monitor and Maintain
Regularly check that social previews are displaying correctly. Update images when page content changes significantly. Monitor social sharing analytics to track click-through rates. A/B test different images and descriptions for high-traffic pages. Keep meta tags synchronized with page title and meta description changes. Set up automated testing for social meta tags as part of your QA process.