Community编程与开发github.com

博客架构生成器(JSON-LD 结构化数据)

为博客文章生成完整、经过验证的 JSON-LD 结构化数据标记,使用 @graph 模式组合多种架构类型,并通过稳定的 @id 引用实现实体链接。

博客架构生成器(JSON-LD 结构化数据) 是什么?

该技能用于为博客文章自动生成符合 Schema.org 标准的 JSON-LD 结构化数据。它通过 @graph 模式将多种架构类型(如 BlogPosting、Person、Organization、BreadcrumbList、FAQPage、ImageObject 和 VideoObject)合并到一个 `<script>` 标签中,并通过稳定的 @id 引用实现实体之间的交叉链接。这对于提升搜索引擎对内容的理解以及 AI 系统的信息提取非常有帮助,尤其是在 AI 引用优化方面——使用 3 种以上架构类型的页面被 AI 引用的可能性提高约 13%。该技能支持 Claude Code、Cursor 等辅助编程代理,用户只需提供博客文章内容或元数据,技能即可自动解析并生成完整的 JSON-LD 标记。此外,它还内置了验证步骤,能检测已弃用的架构类型并确保所有引用和属性符合 Google 及 Schema.org 的要求。

兼容平台~Claude Code~Codex CLI~Cursor✓Gemini CLI
npx skills add https://github.com/AgriciDaniel/claude-blog/tree/main/skills/blog-schema

Installed? Explore more 编程与开发 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

博客架构 —— JSON-LD 结构化数据生成

为博客文章生成完整、经过验证的 JSON-LD 架构标记,使用 @graph 模式。组合多种架构类型到一个 <script> 标签中,并通过稳定的 @id 引用实现实体链接。

工作流程

步骤 1:读取内容

阅读博客文章并提取所有与架构相关的数据:

  • 标题(headline)
  • 作者(姓名、职位、社交链接、资质)
  • 日期(datePublished、dateModified / lastUpdated)
  • 描述(meta description)
  • 常见问题部分(问题和答案对)
  • 图片(封面图片 URL、尺寸、替代文本;内联图片)
  • 组织信息(站点名称、URL、标志)
  • 字数(根据内容长度估算)
  • 标签/分类(用于 BreadcrumbList 分类)
  • Slug(从文件名或 frontmatter 中提取)

步骤 2:生成 BlogPosting 架构

完整的 BlogPosting,包含所有必需和推荐的属性:

{
  "@type": "BlogPosting",
  "@id": "{siteUrl}/blog/{slug}#article",
  "headline": "文章标题(最多 110 字符)",
  "description": "Meta 描述(150-160 字符)",
  "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": "内容的前 200 个字符作为摘要..."
}

必需属性:@type、headline、datePublished、author、publisher、image。 推荐属性:description、dateModified、mainEntityOfPage、wordCount、articleBody(摘要)。

步骤 3:生成 Person 架构

作者架构,使用稳定的 @id 以便交叉引用:

{
  "@type": "Person",
  "@id": "{siteUrl}/author/{author-slug}#person",
  "name": "作者姓名",
  "jobTitle": "角色或职位",
  "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 架构

博客的父组织实体:

{
  "@type": "Organization",
  "@id": "{siteUrl}#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 架构

显示内容层次结构的导航面包屑架构:

{
  "@type": "BreadcrumbList",
  "@id": "{siteUrl}/blog/{slug}#breadcrumb",
  "itemListElement": [
    {
      "@type": "ListItem",
      "position": 1,
      "name": "首页",
      "item": "{siteUrl}"
    },
    {
      "@type": "ListItem",
      "position": 2,
      "name": "分类名称",
      "item": "{siteUrl}/blog/category/{category-slug}"
    },
    {
      "@type": "ListItem",
      "position": 3,
      "name": "文章标题",
      "item": "{siteUrl}/blog/{slug}"
    }
  ]
}

如果没有可用的分类,将“博客”作为第二个面包屑项,URL 使用 {siteUrl}/blog。

步骤 6:生成 FAQPage 架构

从博客文章的常见问题部分提取问答对:

{
  "@type": "FAQPage",
  "@id": "{siteUrl}/blog/{slug}#faq",
  "mainEntity": [
    {
      "@type": "Question",
      "name": "问题是什么?",
      "acceptedAnswer": {
        "@type": "Answer",
        "text": "完整的答案文本(40-60 词,包含统计数据)。"
      }
    }
  ]
}

重要提示:自 2023 年 8 月起,Google 将 FAQ 富结果限制为政府和大健康网站。然而,FAQ 架构标记仍然有价值,因为:

  • AI 系统(ChatGPT、Perplexity、Gemini)会提取 FAQ 数据用于引用
  • 它为未来富结果资格变更提供了结构化内容
  • 它改善了内容组织信号

步骤 7:生成 VideoObject(如果包含视频)

对于文章中嵌入的每个 YouTube 视频,生成 VideoObject 架构:

{
  "@type": "VideoObject",
  "@id": "{siteUrl}/blog/{slug}#video-{index}",
  "name": "视频标题",
  "description": "视频描述摘录(前 200 字符)",
  "thumbnailUrl": "https://img.youtube.com/vi/{videoId}/hqdefault.jpg",
  "uploadDate": "{ISO 8601 日期}",
  "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 数组中。使用 #video-1、#video-2 等作为 @id 片段。从嵌入的 noscript 回退或通过 YouTube Data API(如果通过 blog-google 可用)提取视频元数据。

步骤 7.5:生成 ImageObject

文章主要图片的封面图片架构:

{
  "@type": "ImageObject",
  "@id": "{siteUrl}/blog/{slug}#primaryimage",
  "url": "https://cdn.pixabay.com/photo/.../image.jpg",
  "width": 1200,
  "height": 630,
  "caption": "与替代文本匹配的描述性标题"
}

图片要求:

  • URL 必须可爬取且公开可访问
  • 宽度和高度应反映实际图片尺寸
  • 标题应与图片替代文本匹配或紧密对齐
  • 推荐尺寸:1200x630(兼容 OG)或 1920x1080

步骤 8:验证与警告

检查已弃用的架构类型并应用验证规则:

切勿使用这些已弃用的类型:

  • HowTo - 2023 年 9 月弃用(Google 不再显示富结果)
  • SpecialAnnouncement - 2025 年 7 月弃用
  • Practice Problem - 弃用(教育标记)
  • Dataset - 通用用例已弃用
  • Sitelinks Search Box - 已弃用
  • Q&A - 2026 年 1 月弃用(与 FAQPage 不同)

验证检查:

  1. 所有 @id 引用都解析到 @graph 内的实体
  2. dateModified 等于或晚于 datePublished
  3. headline 不超过 110 个字符
  4. description 在 50-160 个字符之间
  5. 所有 URL 都是绝对路径(非相对路径)
  6. 图片尺寸为正整数
  7. BreadcrumbList 位置从 1 开始连续
  8. 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 模式优势:

  • 单个 script 标签而非多个 —— HTML 更简洁
  • 通过稳定的 @id 引用实现实体链接(例如,作者通过 @id 引用 Person)
  • Google 和 AI 系统能正确解析 @graph 数组
  • 作为单个块更易于维护和更新

输出选项:

  • 嵌入式 HTML - 可直接粘贴到 <head> 或 </body> 之前
  • 独立 JSON - 用于 CMS 架构字段或 API 注入
  • MDX 组件 - 如果项目使用 MDX,则包装在组件中

按用户偏好将生成的架构保存到博客文章文件或单独的架构文件中。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

相关技能