social-metadata-hardening – skill Marketing & SEO cho agent AI
Sửa bản xem trước khi chia sẻ mạng xã hội để URL hiển thị thành thẻ đầy đủ trên Facebook, LinkedIn, X/Twitter, WhatsApp, Telegram và nhiều nền tảng khác. Bao gồm thẻ OG, Twitter card, URL ảnh tuyệt đối và gỡ lỗi.
Cài skill social-metadata-hardening bằng một lệnh
Chọn công cụ bạn đang dùng, copy lệnh và dán vào terminal. Skill sẽ nằm trong thư mục skills của công cụ đó và sẵn sàng dùng ở phiên làm việc tiếp theo.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/social-metadata-hardening-c8108.tgz | tar xz -C ~/.claude/skills
Gọi trong Claude Code: /social-metadata-hardening – rồi mô tả công việc bạn muốn làm.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/social-metadata-hardening-c8108.tgz | tar xz -C ~/.codex/skills
Gọi trong Codex: $social-metadata-hardening – rồi mô tả công việc bạn muốn làm.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/social-metadata-hardening-c8108.tgz | tar xz -C ~/.hermes/skills
Gọi trong Hermes Agent: /social-metadata-hardening – rồi mô tả công việc bạn muốn làm.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/social-metadata-hardening-c8108.tgz | tar xz -C ~/.deepcode/skills
Gọi trong DeepSeek: /social-metadata-hardening – rồi mô tả công việc bạn muốn làm.
Nội dung SKILL.md
Nội dung SKILL.md gốc bằng tiếng Anh.
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
metadataBasecoverage 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
if (!image) throw new Error("An approved preview image is required");
const imageUrl = new URL(image, baseUrl).href;
const pageUrl = new URL(path, baseUrl).href;
if (new URL(imageUrl).protocol !== "https:" || new URL(pageUrl).protocol !== "https:") {
throw new Error("Public metadata URLs must use HTTPS");
}
// Detect MIME type from extension
const ext = new URL(imageUrl).pathname.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 { slug } = await params; // Compatible with async params in newer Next.js.
const post = await getPost(slug);
return buildSocialMetadata({
title: `${post.title} | My Blog`,
description: post.excerpt,
path: `/blog/${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 (approximately 1.91:1; verify crop/requirements on each target platform)
- 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](https://developers.facebook.com/tools/debug/) 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_imagefor full-width images twitter:imagemust be an absolute URL- Use the [Card Validator](https://cards-dev.twitter.com/validator) to test
- Caches hard — use [Post Inspector](https://www.linkedin.com/post-inspector/) to refresh
- Respects
og:tags; ignorestwitter: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 = articlefor 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
| Platform | Tool |
|----------|------|
| Facebook | https://developers.facebook.com/tools/debug/ |
| LinkedIn | https://www.linkedin.com/post-inspector/ |
| Twitter/X | https://cards-dev.twitter.com/validator |
| General | https://metatags.io |
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
- [ ]
metadataBaseset in root layout - [ ] All shareable pages use shared
buildSocialMetadatahelper - [ ] OG image URLs are absolute (start with
https://) - [ ]
secureUrlset equal tourlin OG image block - [ ] Image is 1200×630px, under 8MB, HTTPS
- [ ]
twitter:cardissummary_large_image(notsummary) - [ ] Image alt text present
- [ ] Tags visible in raw HTML (not JavaScript-rendered)
- [ ] All platform debuggers show correct preview
- [ ] Cache refreshed on all platforms after deployment
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.
Skill liên quan
- social-orchestrator – Bộ điều phối thống nhất các kênh mạng xã hội — phối hợp Instagram, Telegram và WhatsApp…
- social-proof-architect – Chọn và đặt các lời chứng thực, nghiên cứu điển hình và bằng chứng xác thực khác khi…
- speed – Khởi chạy trình đọc nhanh RSVP cho văn bản
- subject-line-psychologist – Soạn tiêu đề email và nội dung thông báo phù hợp với đối tượng và vị trí trong chuỗi…
- tax-register – Sổ thuế: thuế đầu ra và đầu vào, thuế khấu trừ đã khấu trừ và đã nhận, số thuế phải nộp…
- telegram-channel-ads – Thẩm định và định giá bài quảng cáo trong kênh Telegram: chỉ số tiếp cận theo quy mô…
- tools-page-seo-optimizer – Quy trình SEO không phụ thuộc framework cho mọi website có nhiều trang công cụ, sản phẩm…
- unslop-commit – Viết lại thông điệp commit để nghe như do một kỹ sư cẩn thận viết. Loại bỏ các từ ngữ…