关于 seo-schema-structured-data
seo-schema-structured-data 是介绍如何创建和检查 Schema.org JSON-LD 结构化数据的技能,涵盖常见实体类型、Google 支持的属性及验证流程,适用于网站维护者和开发者。
主要功能
- 01讲解 JSON-LD 结构与实体关系
- 02介绍常见 Schema.org 实体类型
- 03汇总 Google 支持的属性
- 04通过 MCP 工具提取和生成 Schema
- 05说明结构化数据验证步骤
适用场景
- 01为文章页面添加结构化数据
- 02描述产品或本地商家
- 03检查 URL 中已有的 Schema
- 04发布前验证标记
MCP 相关
README 提及名为 `extract_schema` 和 `generate_schema` 的 MCP 工具,分别用于从 URL 提取结构化数据,以及按目标类型生成标记。
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ autom8minds/ seo-skills --skill seo-schema-structured-data安装后在 Claude Code 中输入/seo-schema-structured-data确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
README.mdRICH_RESULTS_GUIDE.mdSCHEMA_TEMPLATES.mdVALIDATION_RULES.md详细介绍
Schema.org 结构化数据与 JSON-LD
JSON-LD 基础知识
JSON-LD(JavaScript Object Notation for Linked Data)是 Google 推荐的结构化数据格式。它通过 HTML 页面的 <head> 或 <body> 中的 <script> 标签注入。
基本语法
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Article",
"headline": "How to Implement Structured Data",
"author": {
"@type": "Person",
"name": "Jane Smith"
}
}
</script>
核心关键字
| 关键字 | 用途 | 示例 |
|---|---|---|
@context | 声明词汇表(始终为 https://schema.org) | "@context": "https://schema.org" |
@type | 指定实体类型 | "@type": "Article" |
@id | 实体的唯一标识符(支持交叉引用) | "@id": "https://example.com/#organization" |
@graph | 在单个 JSON-LD 块中包含多个实体 | "@graph": [{ ... }, { ... }] |
嵌套实体
实体可以直接嵌套,也可以通过 @id 引用:
{
"@context": "https://schema.org",
"@type": "Article",
"author": {
"@type": "Person",
"name": "Jane Smith",
"@id": "https://example.com/#jane"
},
"publisher": {
"@id": "https://example.com/#organization"
}
}
数组
当一个属性有多个值时,请使用数组:
{
"@type": "Article",
"author": [
{ "@type": "Person", "name": "Jane Smith" },
{ "@type": "Person", "name": "John Doe" }
]
}
@graph 模式(多实体页面)
使用 @graph 描述单个页面上的多个实体(例如,Organization + WebPage + BreadcrumbList):
{
"@context": "https://schema.org",
"@graph": [
{
"@type": "Organization",
"@id": "https://example.com/#organization",
"name": "Example Corp",
"url": "https://example.com"
},
{
"@type": "WebPage",
"@id": "https://example.com/about/#webpage",
"url": "https://example.com/about/",
"name": "About Us",
"isPartOf": { "@id": "https://example.com/#website" }
},
{
"@type": "BreadcrumbList",
"itemListElement": [
{ "@type": "ListItem", "position": 1, "name": "Home", "item": "https://example.com/" },
{ "@type": "ListItem", "position": 2, "name": "About" }
]
}
]
}
Google 支持的 Schema 类型
以下类型可被 Google 识别,并可能触发富媒体搜索结果。每个部分都列出了必需(R)和建议(Rec)的属性。
Article(NewsArticle、BlogPosting)
触发效果:在搜索结果中显示包含标题、图片和日期的文章富媒体搜索结果。
| 属性 | 状态 | 说明 |
|---|---|---|
headline | R | 最多 110 个字符 |
image | R | 宽度至少为 696px;建议提供多张图片 |
datePublished | R | ISO 8601 格式 |
dateModified | Rec | ISO 8601 格式 |
author | R | 包含 name 和 url 的 Person 或 Organization |
publisher | Rec | 包含 name 和 logo 的 Organization |
description | Rec | 文章的简短摘要 |
mainEntityOfPage | Rec | 页面的 URL |
**MCP 工具:**对任意文章 URL 使用 extract_schema 查看其当前结构化数据,然后使用类型为 Article 的 generate_schema 生成符合规范的标记。
Product(包含 Offer、AggregateRating)
触发效果:显示包含价格、库存情况和星级评分的产品富媒体搜索结果。
| 属性 | 状态 | 说明 |
|---|---|---|
name | R | 产品名称 |
image | R | 至少一张图片 |
description | Rec | 产品描述 |
sku | Rec | 库存单位 |
brand | Rec | 品牌名称 |
offers | R | Offer 或 AggregateOffer |
offers.price | R | 数值型价格 |
offers.priceCurrency | R | ISO 4217 货币代码 |
offers.availability | R | ItemAvailability 枚举(例如,https://schema.org/InStock) |
offers.url | Rec | 购买链接 |
aggregateRating | Rec | 包含 ratingValue 和 reviewCount 的 AggregateRating |
review | Rec | 单条 Review 对象 |
嵌套模式:AggregateRating 和 Offer 嵌套在 Product 中:
{
"@type": "Product",
"name": "Widget",
"offers": {
"@type": "Offer",
"price": "29.99",
"priceCurrency": "USD",
"availability": "https://schema.org/InStock"
},
"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": "4.5",
"reviewCount": "120"
}
}
FAQPage(包含 Question / Answer)
触发效果:在搜索结果中显示可展开的 FAQ 手风琴式内容。
| 属性 | 状态 | 说明 |
|---|---|---|
mainEntity | R | Question 对象数组 |
Question.name | R | 问题文本 |
Question.acceptedAnswer | R | 答案对象 |
Answer.text | R | 答案文本(允许使用 HTML) |
规则:
- 仅在页面主要内容为问答列表时使用 FAQPage。
- 每个问题和答案都必须在页面上可见。
- 不要用于论坛或仅包含一个问题的页面(请改用 QAPage)。
HowTo(含 HowToStep)
触发条件:分步操作富媒体搜索结果或轮播。
| 属性 | 状态 | 备注 |
|---|---|---|
name | R | 操作指南标题 |
step | R | HowToStep 对象数组 |
step.name | R | 步骤标题 |
step.text | R | 步骤说明 |
step.image | Rec | 每个步骤的图片 |
step.url | Rec | 页面上指向该步骤的 URL 锚点 |
totalTime | Rec | ISO 8601 时长(例如 PT30M) |
estimatedCost | Rec | MonetaryAmount 对象 |
supply | Rec | 所需的 HowToSupply 项目 |
tool | Rec | 所需的 HowToTool 项目 |
LocalBusiness(及其子类型)
触发条件:本地知识面板、地图包资格数据。
子类型:Restaurant、Dentist、LegalService、RealEstateAgent、MedicalBusiness 等。
| 属性 | 状态 | 备注 |
|---|---|---|
name | R | 商家名称 |
address | R | PostalAddress 对象 |
telephone | Rec | 电话号码 |
openingHoursSpecification | Rec | 营业时间数组 |
geo | Rec | GeoCoordinates(纬度/经度) |
url | Rec | 网站 URL |
image | Rec | 商家照片 |
priceRange | Rec | 例如 $$ 或 $10-50 |
servesCuisine | Rec | 用于 Restaurant 子类型 |
aggregateRating | Rec | AggregateRating |
review | Rec | Review 对象 |
Organization
触发条件:知识面板数据、搜索结果中的徽标。
| 属性 | 状态 | 备注 |
|---|---|---|
name | R | 组织名称 |
url | R | 网站 URL |
logo | R | ImageObject 或 URL(最小尺寸为 112x112px,优先使用正方形) |
sameAs | Rec | 社交资料 URL 数组 |
contactPoint | Rec | ContactPoint 对象 |
address | Rec | PostalAddress |
description | Rec | 简短描述 |
foundingDate | Rec | ISO 8601 日期 |
BreadcrumbList
触发条件:搜索结果中用面包屑导航替代 URL。
| 属性 | 状态 | 备注 |
|---|---|---|
itemListElement | R | ListItem 对象数组 |
ListItem.position | R | 整数(从 1 开始计数) |
ListItem.name | R | 面包屑标签 |
ListItem.item | R* | URL(*最后一项省略) |
WebSite(含用于站点链接搜索框的 SearchAction)
触发条件:品牌相关搜索中的站点链接搜索框。
| 属性 | 状态 | 备注 |
|---|---|---|
url | R | 主页 URL |
name | Rec | 网站名称 |
potentialAction | R | SearchAction 对象 |
SearchAction.target | R | 含有 {search_term_string} 的 URL 模板 |
SearchAction.query-input | R | "required name=search_term_string" |
{
"@type": "WebSite",
"url": "https://example.com/",
"potentialAction": {
"@type": "SearchAction",
"target": "https://example.com/search?q={search_term_string}",
"query-input": "required name=search_term_string"
}
}
Event
触发条件:包含日期、地点和票务信息的活动富媒体搜索结果。
| 属性 | 状态 | 备注 |
|---|---|---|
name | R | 活动名称 |
startDate | R | ISO 8601 日期时间 |
location | R | Place 或 VirtualLocation |
location.name | R | 场地名称 |
location.address | R | PostalAddress |
endDate | Rec | ISO 8601 日期时间 |
description | Rec | 活动描述 |
image | Rec | 活动图片 |
offers | Rec | 含价格/URL/供应情况的 Offer |
performer | Rec | Person 或 Organization |
organizer | Rec | Person 或 Organization |
eventStatus | Rec | EventScheduled、EventCancelled、EventPostponed 等 |
eventAttendanceMode | Rec | OfflineEventAttendanceMode、OnlineEventAttendanceMode、MixedEventAttendanceMode |
食谱
触发条件:包含图片、评分和烹饪时间的食谱富媒体搜索结果。
| 属性 | 状态 | 备注 |
|---|---|---|
name | R | 食谱名称 |
image | R | 不同宽高比的多张图片 |
author | R | 个人或组织 |
datePublished | Rec | ISO 8601 |
description | Rec | 简短描述 |
prepTime | Rec | ISO 8601 时长 |
cookTime | Rec | ISO 8601 时长 |
totalTime | Rec | ISO 8601 时长 |
recipeYield | Rec | 例如,"4 servings" |
recipeIngredient | Rec | 字符串数组 |
recipeInstructions | R | HowToStep 对象数组 |
nutrition | Rec | NutritionInformation(卡路里) |
aggregateRating | Rec | AggregateRating |
video | Rec | VideoObject |
VideoObject
触发条件:包含缩略图、时长和上传日期的视频富媒体搜索结果。
| 属性 | 状态 | 备注 |
|---|---|---|
name | R | 视频标题 |
description | R | 视频描述 |
thumbnailUrl | R | 缩略图 URL |
uploadDate | R | ISO 8601 日期 |
contentUrl | Rec | 视频文件的直接 URL |
embedUrl | Rec | 嵌入 URL |
duration | Rec | ISO 8601 时长 |
interactionStatistic | Rec | 观看次数 |
Course
触发条件:搜索和 Google for Education 中的课程富媒体搜索结果。
| 属性 | 状态 | 备注 |
|---|---|---|
name | R | 课程标题 |
description | R | 课程描述 |
provider | R | 提供课程的组织 |
offers | Rec | 带价格的优惠 |
courseCode | Rec | 标识符 |
hasCourseInstance | Rec | 带日程安排的 CourseInstance |
SoftwareApplication
触发条件:包含评分、价格和操作系统的软件富媒体搜索结果。
| 属性 | 状态 | 备注 |
|---|---|---|
name | R | 应用名称 |
operatingSystem | Rec | 例如,"Windows 10"、"Android" |
applicationCategory | Rec | 例如,"GameApplication"、"BusinessApplication" |
offers | R | 带价格的优惠(免费时使用 "0") |
aggregateRating | Rec | AggregateRating |
review | Rec | Review 对象 |
Review
触发条件:带星级评分的评论摘要。
| 属性 | 状态 | 备注 |
|---|---|---|
itemReviewed | R | 被评论的实体(Product、LocalBusiness 等) |
author | R | 撰写评论的个人 |
reviewRating | R | 带 ratingValue 的评分对象 |
reviewRating.bestRating | Rec | 最高评分值 |
reviewRating.worstRating | Rec | 最低评分值 |
datePublished | Rec | ISO 8601 日期 |
reviewBody | Rec | 评论全文 |
动态 Schema 生成模式
以编程方式构建页面时,请从数据模型生成 Schema:
服务端渲染(Next.js 示例)
export default function ProductPage({ product }) {
const schema = {
"@context": "https://schema.org",
"@type": "Product",
"name": product.title,
"image": product.images,
"description": product.description,
"sku": product.sku,
"brand": { "@type": "Brand", "name": product.brand },
"offers": {
"@type": "Offer",
"price": product.price,
"priceCurrency": "USD",
"availability": product.inStock
? "https://schema.org/InStock"
: "https://schema.org/OutOfStock"
}
};
return (
<>
<script
type="application/ld+json"
dangerouslySetInnerHTML={{ __html: JSON.stringify(schema) }}
/>
{/* Page content */}
</>
);
}
CMS 集成模式
适用于 WordPress、Shopify 或无头 CMS:
- 在模板或插件中将 CMS 字段映射到 Schema 属性。
- 确保价格、供货情况和评分数据来自实时数据源。
- 使用条件逻辑,仅输出有值的属性。
验证方法
步骤 1:富媒体搜索结果测试(Google)
- URL:https://search.google.com/test/rich-results
- 测试标记是否符合富媒体搜索结果的要求。
- 按 Schema 类型报告错误和警告。
步骤 2:Schema 标记验证器(Schema.org)
- URL:https://validator.schema.org/
- 根据完整的 Schema.org 词汇表进行验证(范围比 Google 更广)。
步骤 3:Google Search Console
- 在 增强功能 部分查看结构化数据报告。
- 监控错误、警告和有效项目数量。
- 查看含有结构化数据的页面的索引情况。
MCP 工具: 使用 extract_schema 从任意 URL 提取所有 JSON-LD、Microdata 和 RDFa。使用 generate_schema 并指定目标类型,根据页面内容生成有效标记。
常见陷阱
| 陷阱 | 问题 | 修复方法 |
|---|---|---|
| 不可见内容 | Schema 描述的内容对用户不可见 | 确保每个结构化数据属性都与页面上可见的内容相符 |
| 缺少必填字段 | Google 会忽略不完整的标记 | 始终包含每种类型所需的全部属性 |
@type 错误 | 使用了 Google 不支持的富媒体搜索结果类型 | 仅使用 Google 文档中列出的类型 |
| 虚假评价 | Schema 包含捏造的评分或评价 | 仅标记真实用户的真实评价 |
| 价格过时 | 产品 Schema 显示旧价格 | 根据实时数据动态生成 Schema |
| 多个互相冲突的类型 | 一个页面上有两个数据不同的 Product Schema | 每个实体只使用一个规范 Schema |
| 自引用问题 | @id 指向不存在位置的引用 | 确保每个 @id 引用都有匹配的定义 |
| 日期格式不正确 | 使用 MM/DD/YYYY 而非 ISO 8601 | 始终使用 YYYY-MM-DD 或 YYYY-MM-DDTHH:MM:SS+00:00 |
| HTTP 图片 URL | 图片通过 HTTP 而非 HTTPS 引用 | 所有图片都使用 HTTPS URL |
| 违反垃圾信息政策 | 仅为操纵 SEO 而标记内容 | 遵循 Google 的结构化数据垃圾信息政策 |
相关技能
- seo-on-page-optimization ——用于内容和元标签优化
- seo-technical-audit ——用于抓取和索引问题
- seo-mcp-tools-expert ——用于详细了解 MCP 工具的使用方法
结构化数据的关键 MCP 工具
| 工具 | 用途 |
|---|---|
extract_schema | 从任意 URL 提取现有结构化数据 |
generate_schema | 为指定页面和类型生成有效的 JSON-LD 标记 |
有关可直接使用的 JSON-LD 模板,请参阅 SCHEMA_TEMPLATES.md。 有关 Google 的验证要求,请参阅 VALIDATION_RULES.md。 有关哪些类型会触发哪些富媒体搜索结果,请参阅 RICH_RESULTS_GUIDE.md。