social-metadata-hardening
Skill này làm gì
Công cụ này giúp đảm bảo các liên kết được chia sẻ trên mạng xã hội và ứng dụng nhắn tin hiển thị với bản xem trước đầy đủ, thay vì chỉ là một đường link trơ trọi. Nó khắc phục các vấn đề như thiếu hình ảnh, nội dung sai hoặc bản xem trước cũ.
Khi nào nên dùng
- ✓Khi một liên kết bạn chia sẻ không hiển thị hình ảnh hoặc hiển thị sai hình.
- ✓Khi bạn muốn bản xem trước của liên kết trông đúng như bạn dự định.
- ✓Khi bạn chuẩn bị ra mắt website và muốn đảm bảo mọi liên kết đều hiển thị đẹp ở mọi nơi.
Liên kết skill
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/social-metadata-hardening/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Làm cho liên kết website của tôi hiển thị bản xem trước đẹp trên Facebook và WhatsApp.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Công cụ thêm thông tin quan trọng (như tiêu đề, mô tả và hình ảnh) vào mã của website. Nó cũng đảm bảo hình ảnh có kích thước đúng và định dạng mà các nền tảng mạng xã hội hỗ trợ.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết 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
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
metadataBasewhen 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
…
Câu hỏi thường gặp
Vì sao bản xem trước liên kết của tôi bị lỗi?
Điều này có thể do nhiều nguyên nhân: thiếu thông tin quan trọng (tiêu đề, mô tả, hình ảnh), hình ảnh là đường dẫn tương đối (cần là URL đầy đủ), kích thước hình ảnh sai, hoặc nền tảng mạng xã hội đang hiển thị thông tin cũ (bộ nhớ đệm).
Kích thước lý tưởng cho hình ảnh xem trước là bao nhiêu?
Kích thước khuyến nghị là rộng 1200 pixel và cao 630 pixel. Điều này đảm bảo hình ảnh đẹp trên mọi nền tảng.
Làm sao để cập nhật bản xem trước nếu tôi đã chia sẻ liên kết?
Sau khi sửa lỗi trên website, bạn có thể dùng công cụ riêng của từng nền tảng (như Facebook Debugger hoặc Twitter/X Card Validator) để yêu cầu họ lấy lại thông tin mới của liên kết.
Chi tiết
Mô tả gốc của tác giả
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.
Độ phổ biến
- Sao GitHub
- 48k
- Vị trí xếp hạng
- #5821
- Giấy phép
- MIT
- Cập nhật
- 15/10/2026
Bình luận
- …
Thêm skill từ kho mã này
00-andruia-consultant
48kGiúp agent của bạn bắt đầu hoặc cải thiện các dự án AI. Phân tích mã, gợi ý công cụ và lập kế hoạch hành động bằng tiếng Tây Ban Nha.
007
48kCho phép agent của bạn thực hiện kiểm toán bảo mật và mô hình hóa mối đe dọa. Hữu ích để bảo vệ dự án khỏi các cuộc tấn công và lỗ hổng.
10-andruia-skill-smith
48kGiúp agent của bạn tạo hoặc cải thiện các công cụ AI. Xác định cách công cụ hoạt động, viết tài liệu và kiểm tra cấu trúc.
20-andruia-niche-intelligence
48kGiúp agent của bạn tạo bản tóm tắt về một ngành cụ thể. Hữu ích để hiểu bối cảnh, quy tắc, cách người dùng tương tác và rủi ro của dự án.
Skill tương tự
xurl
394kGiúp agent của bạn đăng, trả lời, tìm kiếm và đọc trên X, gửi tin nhắn riêng và tải lên phương tiện, bằng công cụ xurl đã xác thực.
connections-optimizer
280kCải thiện các kết nối trên mạng xã hội của bạn. Gợi ý ai nên theo dõi hoặc bỏ theo dõi và giúp soạn tin nhắn cá nhân hóa để mở rộng mạng lưới.
content-engine
280kTạo nội dung cho nhiều nền tảng khác nhau. Giúp soạn bài đăng, kịch bản và lịch nội dung phù hợp với các mạng như X, LinkedIn và YouTube.