Add Open Graph + Twitter Card tags — Claude Code
When your URL is pasted into Slack, WhatsApp, LinkedIn, or X, the preview card is built from Open Graph tags. Missing tags give you a bare URL with no image — 3-5x lower click rate.
Fixing this in Claude Code
Anthropic's official terminal coding agent
Claude Code can grep the whole codebase first, plan the change, then edit every affected file. Paste the prompt below into your Claude Code chat and the fix rolls out across the project in one pass.
Using a different tool? Pick your stack:
The prompt for Claude Code
Copy and paste this into your Claude Code chat exactly as-is.
Run Claude Code in the project root and make these exact changes, scanning the whole codebase first: Add Open Graph tags 1. Add <meta property="og:title">, <meta property="og:description"> and <meta property="og:image"> in <head>. 2. Use a 1200x630 image for og:image and host it under a stable URL. 3. Mirror the same values into Twitter Card meta tags (twitter:title, twitter:description, twitter:image).
Why this matters
Roughly half of the traffic to most SaaS and content sites comes from links pasted into messaging apps, Slack channels, X, LinkedIn posts, and AI chats. Every one of those surfaces renders a preview card. No og:image means no preview, which means people scroll past.
Open Graph is the single format that controls all of these previews. You write it once in the HTML head, and Facebook, LinkedIn, Slack, WhatsApp, Telegram, Discord, and Signal all use it. Twitter/X uses a very similar format (twitter:card) — mirror the OG values and you are done.
AI chat tools (ChatGPT, Claude) also fetch OG tags when rendering a link card in their response. A missing og:image makes your site look abandoned in those surfaces too.
How to use this prompt in Claude Code
- 1. Open your Claude Code project.
- 2. Copy the prompt above with the copy button.
- 3. Paste into the Claude Code chat and send.
- 4. Review the diff, accept the changes, redeploy.
- 5. Verify the fix using the checklist below.
Common mistakes to avoid
- error_outlineReferencing og:image with a relative URL — many scrapers require absolute URLs.
- error_outlineUsing a 1024×1024 square image — LinkedIn and Slack crop it.
- error_outlineForgetting to ship the actual image file to /public, so og:image 404s.
- error_outlineUsing the same og:image on every page — fine as a fallback, but article pages deserve their own.
- error_outlineSetting only og:* without twitter:* — X falls back to OG but the card format is different; cards without `twitter:card` default to a smaller layout.
How to verify the fix worked
- check_circlePaste your URL into https://www.opengraph.xyz/ — must render title, description, and a correct 1200×630 image.
- check_circleTest on https://cards-dev.twitter.com/validator — must show a summary_large_image card.
- check_circlePaste the URL into Slack, LinkedIn, and WhatsApp — each should render the preview.
- check_circle`curl -s URL | grep "og:image"` — confirms the tag renders server-side, not after JS.
Frequently asked questions
What is the correct og:image size?expand_more
Do I need both og:* and twitter:*?expand_more
Can I auto-generate og:images per page?expand_more
Want all 34 prompts tailored to your Claude Code site?
Pantra scans your site in 10 seconds, detects the stack, and generates the exact prompts that apply — only the ones you actually need.
Scan my siteRelated Claude Code prompts
Add a 1200×630 Open Graph image — Claude Code
Prompt to create and reference a properly-sized og:image so your link previews look professional on LinkedIn, Slack, WhatsApp, X.
SEOAdd a unique <title> tag to every page — Claude Code
Copy-paste prompt to add a unique, keyword-rich <title> tag to every page in Lovable, Cursor, Bolt, v0, Replit, Windsurf, Claude Code, or Base44.
SEOAdd unique meta descriptions to every page — Claude Code
Prompt to add unique 50-160 character meta descriptions to every page — controls the grey snippet text in Google search results.
SEOFix the H1 tag — exactly one per page — Claude Code
Prompt to enforce exactly one H1 per page with the primary keyword, for Lovable, Cursor, Bolt, v0, Replit, Windsurf, Claude Code, Base44.