Social Metadata Hardening Skill
Fix social sharing so every important URL unfurls as a rich card across all platforms.
When to Use
- Use when shared links show missing, stale, cropped, or incorrect previews on social and chat platforms.
- Use when auditing Open Graph, Twitter/X card, image URL, alt text, or
metadataBase coverage in a web app.
- Use before launch when every public page needs predictable rich previews across LinkedIn, X, Facebook, WhatsApp, Slack, Discord, and Telegram.
Why Previews Break
| Problem |
Root Cause |
| No preview at all |
Missing og:title, og:description, or og:image |
| Broken image |
Relative URL (must be absolute) |
| Wrong image size |
Image not 1200×630px (OG standard) |
| Plain text card |
Twitter card type missing or set to summary |
| Stale preview |
Platform caching old metadata |
| Metadata missing on crawl |
Tags added by client-side JS (crawlers don't run JS) |
The Gold Standard Metadata Block
Every shareable page needs ALL of these in static HTML:
// Next.js App Router — lib/socialMetadata.js
export function buildSocialMetadata({
title,
description,
path, // '/blog/my-post'
image, // '/images/og/my-post.jpg' or full URL
imageAlt,
imageWidth = 1200,
imageHeight = 630,
}) {
const baseUrl = process.env.NEXT_PUBLIC_BASE_URL || 'https://www.yourdomain.com';
// Always produce an absolute URL
const imageUrl = image?.startsWith('http') ? image : `${baseUrl}${image}`;
const pageUrl = `${baseUrl}${path}`;
// Detect MIME type from extension
const ext = imageUrl.split('.').pop().toLowerCase();
const mimeMap = { jpg: 'image/jpeg', jpeg: 'image/jpeg', png: 'image/png', webp: 'image/webp' };
const imageType = mimeMap[ext] || 'image/jpeg';
return {
title,
description,
alternates: { canonical: pageUrl },
openGraph: {
title,
description,
url: pageUrl,
type: 'website', // use 'article' for blog posts
images: [{
url: imageUrl,
secureUrl: imageUrl, // explicit HTTPS version
width: imageWidth,
height: imageHeight,
alt: imageAlt || title,
type: imageType,
}],
},
twitter: {
card: 'summary_large_image', // NOT 'summary' — that shows a tiny image
title,
description,
images: [imageUrl],
},
};
}
Applying the Helper
Static page
// app/about/page.js
import { buildSocialMetadata } from '@/lib/socialMetadata';
export const metadata = buildSocialMetadata({
title: 'About Us | My Site',
description: 'Learn about our team and mission.',
path: '/about',
image: '/images/og/about.jpg',
imageAlt: 'The My Site team',
});
Dynamic page (blog post, tool page)
// app/blog/[slug]/page.js
import { buildSocialMetadata } from '@/lib/socialMetadata';
export async function generateMetadata({ params }) {
const post = await getPost(params.slug);
return buildSocialMetadata({
title: `${post.title} | My Blog`,
description: post.excerpt,
path: `/blog/${params.slug}`,
image: post.ogImage || '/images/og/default.jpg',
imageAlt: post.title,
});
}
Homepage (app/layout.js or app/page.js)
export const metadata = {
metadataBase: new URL('https://www.yourdomain.com'), // REQUIRED for absolute URLs
...buildSocialMetadata({
title: 'My Site — Tagline Here',
description: 'Site-wide description.',
path: '/',
image: '/images/og/home.jpg',
}),
};
⚠️ Set metadataBase when using relative metadata URLs. If your helper already outputs absolute canonical/OG URLs, previews can still work without it.
OG Image Checklist
Good OG images:
- 1200 × 630px (2:1 ratio — works on all platforms)
- Under 8MB (Facebook limit)
- Served over HTTPS
- File name has no spaces (use hyphens)
- Format: JPEG or PNG (WebP works on most but not all crawlers)
- Accessible via GET with no authentication
# Verify your OG image is reachable and correct size
curl -sI https://www.yourdomain.com/images/og/home.jpg | grep -i "content-type\|content-length\|status"
Platform-Specific Notes
Facebook / Meta
- Caches aggressively — use the Sharing Debugger to force recrawl
- Minimum image: 200×200px (but use 1200×630 for quality)
- Needs:
og:title, og:description, og:image, og:url
X / Twitter
- Use
twitter:card = summary_large_image for full-width images
twitter:image must be an absolute URL
- Use the Card Validator to test
LinkedIn
- Caches hard — use Post Inspector to refresh
- Respects
og: tags; ignores twitter: tags
- Image must be ≥1.91:1 aspect ratio
WhatsApp / Telegram
- Read OG tags on first share; cache can last hours
- Re-share after a few hours for the cache to clear naturally
Slack / Discord
- Both use OG tags; both cache
- Discord also supports
og:type = article for richer embeds
Debugging Social Previews
1. Check raw HTML for tags
curl -s https://www.yourdomain.com/blog/my-post | grep -i "og:\|twitter:"
If tags don't appear → they're being added by JavaScript (not crawlable). Fix: move to export const metadata or generateMetadata.
2. Validate with platform tools
3. Force cache refresh
After deploying fixes, paste the URL into each platform's debugger and click "Fetch new scrape information" (or equivalent).
Social Metadata Checklist
Limitations
- Cannot force immediate cache refresh on every social platform; some previews may remain stale after a correct fix.
- Requires publicly reachable deployed URLs for reliable validation with platform debuggers.
- Does not replace brand, accessibility, or legal review of image text, alt text, and preview copy.
1---2name: social-metadata-hardening3description: "Fix social sharing previews so URLs render as rich cards on Facebook, LinkedIn, X/Twitter, WhatsApp, Telegram, and more. Covers OG tags, Twitter cards, absolute image URLs, and debugging."4version: 1.0.05author:6 name: "sickn33 / Antigravity Community"7 github: sickn338tags: [social, metadata, hardening, seo]9category: seo10platforms: [macos, linux, windows]11license: MIT12metadata:13 hermes:14 source: https://skillmd.com/skills/nous-hermeshub/social-metadata-hardening15 upstream: "antigravity-awesome-skills"16 risk: "safe"17 date_added: "2026-05-31"18 original_author: "Antigravity Community"19---2021# Social Metadata Hardening Skill2223Fix social sharing so every important URL unfurls as a rich card across all platforms.2425---2627## When to Use2829- Use when shared links show missing, stale, cropped, or incorrect previews on social and chat platforms.30- Use when auditing Open Graph, Twitter/X card, image URL, alt text, or `metadataBase` coverage in a web app.31- Use before launch when every public page needs predictable rich previews across LinkedIn, X, Facebook, WhatsApp, Slack, Discord, and Telegram.3233---3435## Why Previews Break3637| Problem | Root Cause |38|---------|-----------|39| No preview at all | Missing og:title, og:description, or og:image |40| Broken image | Relative URL (must be absolute) |41| Wrong image size | Image not 1200×630px (OG standard) |42| Plain text card | Twitter card type missing or set to `summary` |43| Stale preview | Platform caching old metadata |44| Metadata missing on crawl | Tags added by client-side JS (crawlers don't run JS) |4546---4748## The Gold Standard Metadata Block4950Every shareable page needs ALL of these in static HTML:5152```js53// Next.js App Router — lib/socialMetadata.js54export function buildSocialMetadata({55 title,56 description,57 path, // '/blog/my-post'58 image, // '/images/og/my-post.jpg' or full URL59 imageAlt,60 imageWidth = 1200,61 imageHeight = 630,62}) {63 const baseUrl = process.env.NEXT_PUBLIC_BASE_URL || 'https://www.yourdomain.com';64 65 // Always produce an absolute URL66 const imageUrl = image?.startsWith('http') ? image : `${baseUrl}${image}`;67 const pageUrl = `${baseUrl}${path}`;68 69 // Detect MIME type from extension70 const ext = imageUrl.split('.').pop().toLowerCase();71 const mimeMap = { jpg: 'image/jpeg', jpeg: 'image/jpeg', png: 'image/png', webp: 'image/webp' };72 const imageType = mimeMap[ext] || 'image/jpeg';7374 return {75 title,76 description,77 alternates: { canonical: pageUrl },78 openGraph: {79 title,80 description,81 url: pageUrl,82 type: 'website', // use 'article' for blog posts83 images: [{84 url: imageUrl,85 secureUrl: imageUrl, // explicit HTTPS version86 width: imageWidth,87 height: imageHeight,88 alt: imageAlt || title,89 type: imageType,90 }],91 },92 twitter: {93 card: 'summary_large_image', // NOT 'summary' — that shows a tiny image94 title,95 description,96 images: [imageUrl],97 },98 };99}100```101102---103104## Applying the Helper105106### Static page107```js108// app/about/page.js109import { buildSocialMetadata } from '@/lib/socialMetadata';110111export const metadata = buildSocialMetadata({112 title: 'About Us | My Site',113 description: 'Learn about our team and mission.',114 path: '/about',115 image: '/images/og/about.jpg',116 imageAlt: 'The My Site team',117});118```119120### Dynamic page (blog post, tool page)121```js122// app/blog/[slug]/page.js123import { buildSocialMetadata } from '@/lib/socialMetadata';124125export async function generateMetadata({ params }) {126 const post = await getPost(params.slug);127 return buildSocialMetadata({128 title: `${post.title} | My Blog`,129 description: post.excerpt,130 path: `/blog/${params.slug}`,131 image: post.ogImage || '/images/og/default.jpg',132 imageAlt: post.title,133 });134}135```136137### Homepage (app/layout.js or app/page.js)138```js139export const metadata = {140 metadataBase: new URL('https://www.yourdomain.com'), // REQUIRED for absolute URLs141 ...buildSocialMetadata({142 title: 'My Site — Tagline Here',143 description: 'Site-wide description.',144 path: '/',145 image: '/images/og/home.jpg',146 }),147};148```149150> ⚠️ **Set `metadataBase` when using relative metadata URLs.** If your helper already outputs absolute canonical/OG URLs, previews can still work without it.151152---153154## OG Image Checklist155156Good OG images:157- **1200 × 630px** (2:1 ratio — works on all platforms)158- **Under 8MB** (Facebook limit)159- Served over **HTTPS**160- File name has **no spaces** (use hyphens)161- Format: **JPEG or PNG** (WebP works on most but not all crawlers)162- **Accessible via GET** with no authentication163164```bash165# Verify your OG image is reachable and correct size166curl -sI https://www.yourdomain.com/images/og/home.jpg | grep -i "content-type\|content-length\|status"167```168169---170171## Platform-Specific Notes172173### Facebook / Meta174- Caches aggressively — use the [Sharing Debugger](https://developers.facebook.com/tools/debug/) to force recrawl175- Minimum image: 200×200px (but use 1200×630 for quality)176- Needs: `og:title`, `og:description`, `og:image`, `og:url`177178### X / Twitter179- Use `twitter:card = summary_large_image` for full-width images180- `twitter:image` must be an absolute URL181- Use the [Card Validator](https://cards-dev.twitter.com/validator) to test182183### LinkedIn184- Caches hard — use [Post Inspector](https://www.linkedin.com/post-inspector/) to refresh185- Respects `og:` tags; ignores `twitter:` tags186- Image must be ≥1.91:1 aspect ratio187188### WhatsApp / Telegram189- Read OG tags on first share; cache can last hours190- Re-share after a few hours for the cache to clear naturally191192### Slack / Discord193- Both use OG tags; both cache194- Discord also supports `og:type = article` for richer embeds195196---197198## Debugging Social Previews199200### 1. Check raw HTML for tags201```bash202curl -s https://www.yourdomain.com/blog/my-post | grep -i "og:\|twitter:"203```204If tags don't appear → they're being added by JavaScript (not crawlable). Fix: move to `export const metadata` or `generateMetadata`.205206### 2. Validate with platform tools207208| Platform | Tool |209|----------|------|210| Facebook | https://developers.facebook.com/tools/debug/ |211| LinkedIn | https://www.linkedin.com/post-inspector/ |212| Twitter/X | https://cards-dev.twitter.com/validator |213| General | https://metatags.io |214215### 3. Force cache refresh216After deploying fixes, paste the URL into each platform's debugger and click "Fetch new scrape information" (or equivalent).217218---219220## Social Metadata Checklist221222- [ ] `metadataBase` set in root layout223- [ ] All shareable pages use shared `buildSocialMetadata` helper224- [ ] OG image URLs are absolute (start with `https://`)225- [ ] `secureUrl` set equal to `url` in OG image block226- [ ] Image is 1200×630px, under 8MB, HTTPS227- [ ] `twitter:card` is `summary_large_image` (not `summary`)228- [ ] Image alt text present229- [ ] Tags visible in raw HTML (not JavaScript-rendered)230- [ ] All platform debuggers show correct preview231- [ ] Cache refreshed on all platforms after deployment232233## Limitations234235- Cannot force immediate cache refresh on every social platform; some previews may remain stale after a correct fix.236- Requires publicly reachable deployed URLs for reliable validation with platform debuggers.237- Does not replace brand, accessibility, or legal review of image text, alt text, and preview copy.