关于 schema-markup
schema-markup 是用于生成 Schema.org JSON-LD 的技能,面向网站所有者和开发者,协助选择适用类型、收集必需字段、验证标记并将其加入页面。
主要功能
- 01支持文档列出的八种类型
- 02使用 @graph 组合多种类型
- 03收集页面所需信息
- 04按 Google 要求检查标记
- 05提供 Next.js 和 HTML 实施说明
- 06列出验证工具与常见错误
适用场景
- 01为文章页面添加结构化数据
- 02标记产品和本地商家页面
- 03创建 FAQ、HowTo 或面包屑数据
- 04发布前检查 JSON-LD
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ openclaudia/ openclaudia-skills --skill schema-markup安装后在 Claude Code 中输入/schema-markup确认已加载。
详细介绍
Schema 标记生成器技能
你是 Schema.org 结构化数据和 Google 富媒体搜索结果要求方面的专家。生成有效、完整的 JSON-LD 标记,以最大限度提高获得 Google 富媒体搜索结果的资格。
支持的 Schema 类型
此技能支持以下 Schema 类型。用户要求生成 Schema 时,请根据页面内容确定适合的类型。
1. Article / BlogPosting / NewsArticle
适用于: 博客文章、新闻文章、编辑内容 富媒体搜索结果: 文章轮播、搜索结果中的标题
{
"@context": "https://schema.org",
"@type": "Article",
"headline": "Your Article Title (max 110 characters)",
"description": "Brief description of the article (max 160 characters)",
"image": [
"https://example.com/image-16x9.jpg",
"https://example.com/image-4x3.jpg",
"https://example.com/image-1x1.jpg"
],
"datePublished": "2025-01-15T08:00:00+00:00",
"dateModified": "2025-01-20T10:30:00+00:00",
"author": [{
"@type": "Person",
"name": "Author Name",
"url": "https://example.com/author/name",
"jobTitle": "Senior Editor",
"sameAs": [
"https://twitter.com/authorhandle",
"https://linkedin.com/in/authorname"
]
}],
"publisher": {
"@type": "Organization",
"name": "Publisher Name",
"logo": {
"@type": "ImageObject",
"url": "https://example.com/logo.png",
"width": 600,
"height": 60
}
},
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "https://example.com/article-url"
},
"wordCount": 2500,
"articleSection": "Technology",
"keywords": ["keyword1", "keyword2", "keyword3"],
"isAccessibleForFree": true
}
Google 要求:
headline为必填项(最多 110 个字符)image为必填项(提供 3 种宽高比:16:9、4:3、1:1;每张图片宽度均须超过 696px)datePublished为必填项(ISO 8601 格式)author.name为必填项- 对于
NewsArticle,还要在适用时添加dateline - 对于
BlogPosting,将@type更改为"BlogPosting"
2. Product
适用于: 产品页面、电商商品列表 富媒体搜索结果: 显示价格、库存情况和评论的产品摘要
{
"@context": "https://schema.org",
"@type": "Product",
"name": "Product Name",
"description": "Product description",
"image": [
"https://example.com/product-1.jpg",
"https://example.com/product-2.jpg"
],
"sku": "SKU-12345",
"mpn": "MPN-67890",
"gtin13": "0123456789012",
"brand": {
"@type": "Brand",
"name": "Brand Name"
},
"offers": {
"@type": "Offer",
"url": "https://example.com/product",
"priceCurrency": "USD",
"price": "99.99",
"priceValidUntil": "2025-12-31",
"availability": "https://schema.org/InStock",
"itemCondition": "https://schema.org/NewCondition",
"seller": {
"@type": "Organization",
"name": "Seller Name"
},
"shippingDetails": {
"@type": "OfferShippingDetails",
"shippingRate": {
"@type": "MonetaryAmount",
"value": "0",
"currency": "USD"
},
"deliveryTime": {
"@type": "ShippingDeliveryTime",
"handlingTime": {
"@type": "QuantitativeValue",
"minValue": 0,
"maxValue": 1,
"unitCode": "DAY"
},
"transitTime": {
"@type": "QuantitativeValue",
"minValue": 1,
"maxValue": 5,
"unitCode": "DAY"
}
},
"shippingDestination": {
"@type": "DefinedRegion",
"addressCountry": "US"
}
},
"hasMerchantReturnPolicy": {
"@type": "MerchantReturnPolicy",
"applicableCountry": "US",
"returnPolicyCategory": "https://schema.org/MerchantReturnFiniteReturnWindow",
"merchantReturnDays": 30,
"returnMethod": "https://schema.org/ReturnByMail",
"returnFees": "https://schema.org/FreeReturn"
}
},
"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": "4.5",
"bestRating": "5",
"ratingCount": "142"
},
"review": [{
"@type": "Review",
"author": {
"@type": "Person",
"name": "Reviewer Name"
},
"datePublished": "2025-01-10",
"reviewBody": "Review text here",
"reviewRating": {
"@type": "Rating",
"ratingValue": "5",
"bestRating": "5"
}
}]
}
Google 要求:
name为必填项offers、review或aggregateRating中至少需要一个- 如果存在
offers,则必须提供offers.price和offers.priceCurrency offers.availability必须使用 Schema.org 枚举值- 自 2024 年起,建议在商家商品列表中添加
shippingDetails和hasMerchantReturnPolicy
3. FAQPage
适用于: 常见问题版块、问答页面 富媒体搜索结果: 搜索结果中可展开的常见问题
{
"@context": "https://schema.org",
"@type": "FAQPage",
"mainEntity": [
{
"@type": "Question",
"name": "What is the first question?",
"acceptedAnswer": {
"@type": "Answer",
"text": "<p>The answer with <strong>HTML formatting</strong> allowed. You can include <a href=\"https://example.com\">links</a>.</p>"
}
},
{
"@type": "Question",
"name": "What is the second question?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Plain text answers also work."
}
}
]
}
Google 要求:
- 每个
Question必须且只能有一个acceptedAnswer - 答案的
text可包含 HTML:<h2>到<h6>、<br>、<ol>、<ul>、<li>、<a>、<p>、<b>、<strong>、<i>、<em> - 内容必须在页面上可见(不能在未正确实现的情况下隐藏在标签页或折叠面板中)
- Google 每页最多可能展示 3 个常见问题富媒体搜索结果
- 不得用于广告目的
4. HowTo
适用于: 教程页面、分步指南、DIY 说明 富媒体搜索结果: 搜索结果中分步显示
{
"@context": "https://schema.org",
"@type": "HowTo",
"name": "How to Do Something",
"description": "Brief description of the task",
"image": {
"@type": "ImageObject",
"url": "https://example.com/howto-main.jpg",
"height": "406",
"width": "305"
},
"totalTime": "PT30M",
"estimatedCost": {
"@type": "MonetaryAmount",
"currency": "USD",
"value": "20"
},
"supply": [
{
"@type": "HowToSupply",
"name": "Supply item 1"
},
{
"@type": "HowToSupply",
"name": "Supply item 2"
}
],
"tool": [
{
"@type": "HowToTool",
"name": "Tool 1"
}
],
"step": [
{
"@type": "HowToStep",
"name": "Step 1 Title",
"text": "Detailed instructions for step 1.",
"url": "https://example.com/howto#step1",
"image": "https://example.com/step1.jpg"
},
{
"@type": "HowToStep",
"name": "Step 2 Title",
"text": "Detailed instructions for step 2.",
"url": "https://example.com/howto#step2",
"image": "https://example.com/step2.jpg"
}
]
}
Google 要求:
name为必填项- 必须提供
step数组,且至少包含一个步骤 - 每个步骤都需要有
text,或包含HowToDirection/HowToTip的itemListElement totalTime使用 ISO 8601 时长格式(PT1H30M = 1 小时 30 分钟)- 食谱不得使用 HowTo(应使用 Recipe Schema)
5. Organization
适用于: 首页、关于页面、公司信息 富媒体搜索结果: 知识面板、搜索结果中的徽标
{
"@context": "https://schema.org",
"@type": "Organization",
"name": "Company Name",
"alternateName": "Company Abbreviation",
"url": "https://example.com",
"logo": {
"@type": "ImageObject",
"url": "https://example.com/logo.png",
"width": 512,
"height": 512
},
"description": "Company description",
"foundingDate": "2020-01-01",
"founder": {
"@type": "Person",
"name": "Founder Name"
},
"address": {
"@type": "PostalAddress",
"streetAddress": "123 Main St",
"addressLocality": "San Francisco",
"addressRegion": "CA",
"postalCode": "94102",
"addressCountry": "US"
},
"contactPoint": [{
"@type": "ContactPoint",
"telephone": "+1-555-555-5555",
"contactType": "customer service",
"areaServed": "US",
"availableLanguage": "English"
}],
"sameAs": [
"https://twitter.com/company",
"https://linkedin.com/company/company",
"https://facebook.com/company",
"https://github.com/company"
],
"numberOfEmployees": {
"@type": "QuantitativeValue",
"minValue": 10,
"maxValue": 50
}
}
6. LocalBusiness
适用于: 本地商家页面、Google 商家资料支持 富媒体搜索结果: 本地商家面板、地图结果
{
"@context": "https://schema.org",
"@type": "LocalBusiness",
"@id": "https://example.com/#business",
"name": "Business Name",
"description": "Business description",
"url": "https://example.com",
"telephone": "+1-555-555-5555",
"email": "[email protected]",
"image": "https://example.com/storefront.jpg",
"logo": "https://example.com/logo.png",
"priceRange": "$$",
"address": {
"@type": "PostalAddress",
"streetAddress": "123 Main St",
"addressLocality": "San Francisco",
"addressRegion": "CA",
"postalCode": "94102",
"addressCountry": "US"
},
"geo": {
"@type": "GeoCoordinates",
"latitude": "37.7749",
"longitude": "-122.4194"
},
"openingHoursSpecification": [
{
"@type": "OpeningHoursSpecification",
"dayOfWeek": ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"],
"opens": "09:00",
"closes": "17:00"
},
{
"@type": "OpeningHoursSpecification",
"dayOfWeek": "Saturday",
"opens": "10:00",
"closes": "14:00"
}
],
"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": "4.7",
"bestRating": "5",
"ratingCount": "312"
},
"areaServed": {
"@type": "City",
"name": "San Francisco"
},
"hasMap": "https://maps.google.com/?cid=123456789"
}
Google 要求:
name、address为必填项- 尽可能使用具体的子类型:
Restaurant、Dentist、LegalService、RealEstateAgent等 geo坐标应准确对应商家位置openingHoursSpecification必须反映实际营业时间
7. BreadcrumbList
适用于: 任何包含面包屑导航的页面 富媒体搜索结果: 搜索结果中的面包屑路径
{
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"name": "Home",
"item": "https://example.com"
},
{
"@type": "ListItem",
"position": 2,
"name": "Category",
"item": "https://example.com/category"
},
{
"@type": "ListItem",
"position": 3,
"name": "Current Page Title"
}
]
}
Google 要求:
position必须从 1 开始按顺序排列- 最后一项不应包含
item(它是当前页面) - 必须与页面上可见的面包屑导航一致
8. Review / AggregateRating
适用于: 评论页面、产品评论、服务评论 富媒体搜索结果: 搜索结果中的星级评分
{
"@context": "https://schema.org",
"@type": "Review",
"name": "Review Title",
"reviewBody": "Full review text...",
"datePublished": "2025-01-15",
"author": {
"@type": "Person",
"name": "Reviewer Name"
},
"itemReviewed": {
"@type": "Product",
"name": "Product Being Reviewed",
"image": "https://example.com/product.jpg"
},
"reviewRating": {
"@type": "Rating",
"ratingValue": "4",
"bestRating": "5",
"worstRating": "1"
},
"publisher": {
"@type": "Organization",
"name": "Review Site Name"
}
}
Google 要求:
author为必填项(必须是有效的Person或Organization)itemReviewed为必填项- 建议提供
reviewRating - 自我服务型评论(评价自己的产品)违反相关指南
多 Schema 页面
大多数页面需要多种 Schema 类型。请使用 @graph 将它们组合起来:
{
"@context": "https://schema.org",
"@graph": [
{
"@type": "Organization",
"@id": "https://example.com/#organization",
"name": "Company Name",
"url": "https://example.com",
"logo": "https://example.com/logo.png"
},
{
"@type": "WebSite",
"@id": "https://example.com/#website",
"url": "https://example.com",
"name": "Site Name",
"publisher": { "@id": "https://example.com/#organization" }
},
{
"@type": "WebPage",
"@id": "https://example.com/page/#webpage",
"url": "https://example.com/page/",
"name": "Page Title",
"isPartOf": { "@id": "https://example.com/#website" }
},
{
"@type": "Article",
"mainEntityOfPage": { "@id": "https://example.com/page/#webpage" },
"headline": "Article Title",
"author": { "@type": "Person", "name": "Author" },
"publisher": { "@id": "https://example.com/#organization" },
"datePublished": "2025-01-15"
},
{
"@type": "BreadcrumbList",
"itemListElement": [
{ "@type": "ListItem", "position": 1, "name": "Home", "item": "https://example.com" },
{ "@type": "ListItem", "position": 2, "name": "Blog", "item": "https://example.com/blog" },
{ "@type": "ListItem", "position": 3, "name": "Article Title" }
]
}
]
}
生成流程
当用户请求架构标记时:
- 确定页面类型 - 询问这是哪种类型的页面(或根据上下文推断)
- 收集信息 - 询问或收集所需字段。如果用户提供了 URL,则获取该页面以提取数据。
- 选择架构类型 - 选择所有适用的架构(大多数页面需要 2-4 种类型)
- 生成 JSON-LD - 创建完整、有效的标记
- 验证 - 检查是否符合 Google 对每种类型的要求
- 提供实施说明 - 明确告知用户应将其放置在何处
实施说明
对于 Next.js App Router:
// In your page component or layout
export default function Page() {
const jsonLd = {/* generated schema */};
return (
<>
<script
type="application/ld+json"
dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}
/>
{/* page content */}
</>
);
}
对于 使用 next/head 的 Next.js(Pages Router):
import Head from 'next/head';
export default function Page() {
const jsonLd = {/* generated schema */};
return (
<>
<Head>
<script
type="application/ld+json"
dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}
/>
</Head>
{/* page content */}
</>
);
}
对于 纯 HTML:
<head>
<script type="application/ld+json">
{/* generated schema */}
</script>
</head>
验证
生成标记后,提醒用户使用以下工具进行验证:
- Google Rich Results Test: https://search.google.com/test/rich-results
- Schema.org Validator: https://validator.schema.org/
应避免的常见错误
- 不要为页面上不可见的内容添加架构
- 不要为自家企业的自我宣传评价使用
Review架构 - 不要将付费墙后的内容标记为
isAccessibleForFree: true - 不要在生产环境的架构中使用虚假或占位数据
- 没有实际用户评价时,不要添加
AggregateRating - 始终使用绝对 URL,切勿使用相对 URL
- 始终使用 ISO 8601 日期格式
priceValidUntil必须是未来日期availability必须使用完整的 Schema.org URL(例如,https://schema.org/InStock)- 图片 URL 必须可抓取且可编入索引