关于 blog-schema
blog-schema 是为博客文章生成 JSON-LD 结构化数据的技能,将相互关联的架构实体整合到单个 @graph 区块中。适合需要根据文章、作者、组织及媒体信息生成标记的博客发布者,并在输出前进行校验。
主要功能
- 01生成 BlogPosting 等相关架构类型
- 02通过稳定的 @id 引用关联实体
- 03构建单个 JSON-LD @graph 区块
- 04校验引用、日期、URL 与字段
- 05输出嵌入式 HTML、JSON 或 MDX
适用场景
- 01为博客文章添加结构化数据
- 02创建作者与组织实体标记
- 03描述 FAQ、面包屑、图片和视频
- 04保存前检查生成的架构数据
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ infrasity-labs/ dev-gtm-claude-skills --skill blog-schema安装后在 Claude Code 中输入/blog-schema确认已加载。
详细介绍
博客 Schema:JSON-LD 结构化数据生成
使用 @graph 模式,为博客文章生成完整且经过验证的 JSON-LD Schema 标记。将多种 Schema 类型合并到单个 script 标签中,并使用稳定的 @id 引用来关联实体。
工作流
步骤 1:读取内容
阅读博客文章并提取所有与 Schema 相关的数据:
- 标题(headline)
- 作者(姓名、职位、社交链接、资历)
- 日期(datePublished、dateModified / lastUpdated)
- 描述(元描述)
- FAQ 部分(问题和答案对)
- 图片(封面图片 URL、尺寸、替代文本;内嵌图片)
- 组织信息(站点名称、URL、徽标)
- 字数(根据内容长度估算)
- 标签/类别(用于 BreadcrumbList 类别)
- Slug(来自文件名或 frontmatter)
步骤 2:生成 BlogPosting Schema
填写完整的 BlogPosting,包含所有必需属性和推荐属性:
{
"@type": "BlogPosting",
"@id": "{siteUrl}/blog/{slug}#article",
"headline": "Post title (max 110 chars)",
"description": "Meta description (150-160 chars)",
"datePublished": "YYYY-MM-DD",
"dateModified": "YYYY-MM-DD",
"author": { "@id": "{siteUrl}/author/{author-slug}#person" },
"publisher": { "@id": "{siteUrl}#organization" },
"image": { "@id": "{siteUrl}/blog/{slug}#primaryimage" },
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "{siteUrl}/blog/{slug}"
},
"wordCount": 2400,
"articleBody": "First 200 characters of content as excerpt..."
}
必需属性:@type、headline、datePublished、author、publisher、image。 推荐属性:description、dateModified、mainEntityOfPage、wordCount、 articleBody(摘录)。
步骤 3:生成 Person Schema
使用稳定的 @id 进行交叉引用的作者 Schema:
{
"@type": "Person",
"@id": "{siteUrl}/author/{author-slug}#person",
"name": "Author Name",
"jobTitle": "Role or Title",
"url": "{siteUrl}/author/{author-slug}",
"sameAs": [
"https://twitter.com/handle",
"https://linkedin.com/in/handle",
"https://github.com/handle"
]
}
可选属性(有可用信息时添加):
alumniOf- 教育机构(Organization 类型)worksFor- 雇主(如果是同一实体,则引用 Organization @id)
步骤 4:生成 Organization Schema
博客所属的上级组织实体:
{
"@type": "Organization",
"@id": "{siteUrl}#organization",
"name": "Organization Name",
"url": "{siteUrl}",
"logo": {
"@type": "ImageObject",
"url": "{siteUrl}/logo.png",
"width": 600,
"height": 60
},
"sameAs": [
"https://twitter.com/org",
"https://linkedin.com/company/org",
"https://github.com/org"
]
}
徽标要求:必须是有效的图片 URL。Google 建议徽标至少为 112x112px,最大宽度为 600px。对于 BlogPosting 发布者,建议使用矩形徽标。
步骤 5:生成 BreadcrumbList
显示内容层级的导航面包屑 Schema:
{
"@type": "BreadcrumbList",
"@id": "{siteUrl}/blog/{slug}#breadcrumb",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"name": "Home",
"item": "{siteUrl}"
},
{
"@type": "ListItem",
"position": 2,
"name": "Category Name",
"item": "{siteUrl}/blog/category/{category-slug}"
},
{
"@type": "ListItem",
"position": 3,
"name": "Post Title",
"item": "{siteUrl}/blog/{slug}"
}
]
}
如果没有可用的类别,请将 “Blog” 用作第二个面包屑项,并使用
{siteUrl}/blog 作为 URL。
步骤 6:生成 FAQPage Schema
从博客文章的 FAQ 部分提取问答对:
{
"@type": "FAQPage",
"@id": "{siteUrl}/blog/{slug}#faq",
"mainEntity": [
{
"@type": "Question",
"name": "What is the question?",
"acceptedAnswer": {
"@type": "Answer",
"text": "The complete answer text (40-60 words with statistic)."
}
}
]
}
重要说明:自 2023 年 8 月起,Google 将 FAQ 富媒体搜索结果限制为政府和健康类网站。不过,FAQ Schema 标记仍然有价值,因为:
- AI 系统(ChatGPT、Perplexity、Gemini)会提取 FAQ 数据用于引用
- 它能为未来富媒体搜索结果资格规则的变更结构化内容
- 它能改善内容组织信号
步骤 7:生成 VideoObject(如果包含视频)
为文章中嵌入的每个 YouTube 视频生成 VideoObject Schema:
{
"@type": "VideoObject",
"@id": "{siteUrl}/blog/{slug}#video-{index}",
"name": "Video title",
"description": "Video description excerpt (first 200 chars)",
"thumbnailUrl": "https://img.youtube.com/vi/{videoId}/hqdefault.jpg",
"uploadDate": "{ISO 8601 date}",
"contentUrl": "https://www.youtube.com/watch?v={videoId}",
"embedUrl": "https://www.youtube.com/embed/{videoId}",
"duration": "PT{M}M{S}S",
"interactionStatistic": {
"@type": "InteractionCounter",
"interactionType": { "@type": "WatchAction" },
"userInteractionCount": {viewCount}
}
}
将每个 VideoObject 添加到 @graph 数组中。@id 片段使用 #video-1、#video-2 等。可从嵌入内容的 noscript 备用内容中提取视频元数据;如果 blog-google 可用,也可以通过 YouTube Data API 提取。
步骤 7.5:生成 ImageObject
为文章的主图片生成封面图片 Schema:
{
"@type": "ImageObject",
"@id": "{siteUrl}/blog/{slug}#primaryimage",
"url": "https://cdn.pixabay.com/photo/.../image.jpg",
"width": 1200,
"height": 630,
"caption": "Descriptive caption matching alt text"
}
图片要求:
- URL 必须可供爬取且可公开访问
- 宽度和高度应与图片的实际尺寸一致
- 说明应与图片替代文本相同或大致一致
- 建议尺寸:1200x630(兼容 OG)或 1920x1080
第 8 步:验证与警告
检查已弃用的架构类型,并应用验证规则:
绝不要使用以下已弃用类型:
- HowTo - 于 2023 年 9 月弃用(Google 不再显示富媒体搜索结果)
- SpecialAnnouncement - 于 2025 年 7 月弃用
- Practice Problem - 已弃用(教育标记)
- Dataset - 已弃用,不再适用于一般用途
- Sitelinks Search Box - 已弃用
- Q&A - 于 2026 年 1 月弃用(与 FAQPage 不同)
验证检查:
- 所有 @id 引用都能解析到 @graph 中的实体
- dateModified 等于或晚于 datePublished
- headline 不超过 110 个字符
- description 长度为 50-160 个字符
- 所有 URL 都是绝对 URL(不是相对 URL)
- 图像尺寸为正整数
- BreadcrumbList 的 position 从 1 开始并按顺序递增
- FAQPage 至少包含 2 个问题
AI 引用优化说明: 使用 3 种或更多架构类型的页面,被 AI 引用的可能性约高 13%。此技能最多生成 7 种类型(BlogPosting、Person、Organization、BreadcrumbList、FAQPage、ImageObject、VideoObject),以最大限度地提升搜索引擎理解能力和 AI 提取效果。
第 9 步:输出
使用 @graph 模式将所有架构合并到单个 <script> 标签中:
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@graph": [
{ "@type": "BlogPosting", ... },
{ "@type": "Person", ... },
{ "@type": "Organization", ... },
{ "@type": "BreadcrumbList", ... },
{ "@type": "FAQPage", ... },
{ "@type": "VideoObject", ... },
{ "@type": "ImageObject", ... }
]
}
</script>
@graph 模式的优势:
- 使用单个脚本标签而非多个,HTML 更简洁
- 通过稳定的 @id 引用关联实体(例如,作者通过 @id 引用 Person)
- Google 和 AI 系统能够正确解析 @graph 数组
- 作为单个代码块更易于维护和更新
输出选项:
- 嵌入式 HTML - 可直接粘贴到
<head>或</body>之前 - 独立 JSON - 用于 CMS 架构字段或通过 API 注入
- MDX 组件 - 如果项目使用 MDX,则封装在组件中
根据用户的偏好,将生成的架构保存到博客文章文件或单独的架构文件中。