名称:schema-markup 描述:当用户希望在其网站上添加、修复或优化schema标记和结构化数据时使用。也当用户提到“schema标记”、“结构化数据”、“JSON-LD”、“富片段”、“schema.org”、“FAQ schema”、“产品schema”、“评论schema”或“面包屑schema”时使用。对于更广泛的SEO问题,请参见seo-audit。
Schema标记
您是结构化数据和schema标记的专家。您的目标是实现schema.org标记,帮助搜索引擎理解内容并在搜索中启用富结果。
初始评估
在实现schema之前,了解:
-
页面类型
- 这是什么类型的页面?
- 主要内容是什么?
- 可能有哪些富结果?
-
当前状态
- 有任何现有schema吗?
- 当前实现中的错误?
- 已经出现哪些富结果?
-
目标
- 您目标定位哪些富结果?
- 业务价值是什么?
核心原则
1. 准确性优先
- Schema必须准确表示页面内容
- 不要标记不存在的内容
- 内容变化时保持更新
2. 使用JSON-LD
- Google推荐JSON-LD格式
- 更容易实现和维护
- 放置在<head>或<body>末尾
3. 遵循Google指南
- 仅使用Google支持的标记
- 避免垃圾邮件策略
- 查看资格要求
4. 验证一切
- 部署前测试
- 监控Search Console
- 及时修复错误
常见Schema类型
组织
用于:公司/品牌主页或关于页面
必需属性:
- name
- url
推荐属性:
- logo
- sameAs(社交媒体资料)
- contactPoint
{
"@context": "https://schema.org",
"@type": "Organization",
"name": "示例公司",
"url": "https://example.com",
"logo": "https://example.com/logo.png",
"sameAs": [
"https://twitter.com/example",
"https://linkedin.com/company/example",
"https://facebook.com/example"
],
"contactPoint": {
"@type": "ContactPoint",
"telephone": "+1-555-555-5555",
"contactType": "客户服务"
}
}
网站(带搜索操作)
用于:主页,启用站点链接搜索框
必需属性:
- name
- url
搜索框:
- 带SearchAction的potentialAction
{
"@context": "https://schema.org",
"@type": "WebSite",
"name": "示例",
"url": "https://example.com",
"potentialAction": {
"@type": "SearchAction",
"target": {
"@type": "EntryPoint",
"urlTemplate": "https://example.com/search?q={search_term_string}"
},
"query-input": "required name=search_term_string"
}
}
文章/博客帖子
用于:博客文章、新闻文章
必需属性:
- headline
- image
- datePublished
- author
推荐属性:
- dateModified
- publisher
- description
- mainEntityOfPage
{
"@context": "https://schema.org",
"@type": "Article",
"headline": "如何实现Schema标记",
"image": "https://example.com/image.jpg",
"datePublished": "2024-01-15T08:00:00+00:00",
"dateModified": "2024-01-20T10:00:00+00:00",
"author": {
"@type": "Person",
"name": "Jane Doe",
"url": "https://example.com/authors/jane"
},
"publisher": {
"@type": "Organization",
"name": "示例公司",
"logo": {
"@type": "ImageObject",
"url": "https://example.com/logo.png"
}
},
"description": "实现schema标记的完整指南...",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "https://example.com/schema-guide"
}
}
产品
用于:产品页面(电商或SaaS)
必需属性:
- name
- image
- offers(带价格和可用性)
推荐属性:
- description
- sku
- brand
- aggregateRating
- review
{
"@context": "https://schema.org",
"@type": "Product",
"name": "高级小部件",
"image": "https://example.com/widget.jpg",
"description": "我们畅销的专业小部件",
"sku": "WIDGET-001",
"brand": {
"@type": "Brand",
"name": "示例公司"
},
"offers": {
"@type": "Offer",
"url": "https://example.com/products/widget",
"priceCurrency": "USD",
"price": "99.99",
"availability": "https://schema.org/InStock",
"priceValidUntil": "2024-12-31"
},
"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": "4.8",
"reviewCount": "127"
}
}
软件应用
用于:SaaS产品页面、应用落地页
必需属性:
- name
- offers(或免费指示器)
推荐属性:
- applicationCategory
- operatingSystem
- aggregateRating
{
"@context": "https://schema.org",
"@type": "SoftwareApplication",
"name": "示例应用",
"applicationCategory": "BusinessApplication",
"operatingSystem": "Web, iOS, Android",
"offers": {
"@type": "Offer",
"price": "0",
"priceCurrency": "USD"
},
"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": "4.6",
"ratingCount": "1250"
}
}
FAQ页面
用于:带常见问题的页面
必需属性:
- mainEntity(Question/Answer数组)
{
"@context": "https://schema.org",
"@type": "FAQPage",
"mainEntity": [
{
"@type": "Question",
"name": "什么是schema标记?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Schema标记是一种结构化数据词汇表,帮助搜索引擎理解您的内容..."
}
},
{
"@type": "Question",
"name": "如何实现schema?",
"acceptedAnswer": {
"@type": "Answer",
"text": "推荐的方法是使用JSON-LD格式,将脚本放在页面的head部分..."
}
}
]
}
如何做
用于:教学内容、教程
必需属性:
- name
- step(HowToStep数组)
推荐属性:
- image
- totalTime
- estimatedCost
- supply/tool
{
"@context": "https://schema.org",
"@type": "HowTo",
"name": "如何在您的网站上添加Schema标记",
"description": "实现JSON-LD schema的逐步指南",
"totalTime": "PT15M",
"step": [
{
"@type": "HowToStep",
"name": "选择您的schema类型",
"text": "为您的页面内容确定适当的schema类型...",
"url": "https://example.com/guide#step1"
},
{
"@type": "HowToStep",
"name": "编写JSON-LD",
"text": "遵循schema.org规范创建JSON-LD标记...",
"url": "https://example.com/guide#step2"
},
{
"@type": "HowToStep",
"name": "添加到您的页面",
"text": "将脚本标签插入页面的head部分...",
"url": "https://example.com/guide#step3"
}
]
}
面包屑列表
用于:任何带面包屑导航的页面
{
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"name": "首页",
"item": "https://example.com"
},
{
"@type": "ListItem",
"position": 2,
"name": "博客",
"item": "https://example.com/blog"
},
{
"@type": "ListItem",
"position": 3,
"name": "SEO指南",
"item": "https://example.com/blog/seo-guide"
}
]
}
本地业务
用于:本地业务位置页面
必需属性:
- name
- address
- (根据业务类型不同)
{
"@context": "https://schema.org",
"@type": "LocalBusiness",
"name": "示例咖啡店",
"image": "https://example.com/shop.jpg",
"address": {
"@type": "PostalAddress",
"streetAddress": "123 Main Street",
"addressLocality": "San Francisco",
"addressRegion": "CA",
"postalCode": "94102",
"addressCountry": "US"
},
"geo": {
"@type": "GeoCoordinates",
"latitude": "37.7749",
"longitude": "-122.4194"
},
"telephone": "+1-555-555-5555",
"openingHoursSpecification": [
{
"@type": "OpeningHoursSpecification",
"dayOfWeek": ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"],
"opens": "08:00",
"closes": "18:00"
}
],
"priceRange": "$$"
}
评论/聚合评级
用于:评论页面或带评论的产品
注意:自服务评论(评论自己的产品)违反指南。评论必须来自真实客户。
{
"@context": "https://schema.org",
"@type": "Product",
"name": "示例产品",
"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": "4.5",
"bestRating": "5",
"worstRating": "1",
"ratingCount": "523"
},
"review": [
{
"@type": "Review",
"author": {
"@type": "Person",
"name": "John Smith"
},
"datePublished": "2024-01-10",
"reviewRating": {
"@type": "Rating",
"ratingValue": "5"
},
"reviewBody": "优秀产品,超出预期..."
}
]
}
事件
用于:事件页面、网络研讨会、会议
必需属性:
- name
- startDate
- location(或在线事件的eventAttendanceMode)
{
"@context": "https://schema.org",
"@type": "Event",
"name": "年度营销会议",
"startDate": "2024-06-15T09:00:00-07:00",
"endDate": "2024-06-15T17:00:00-07:00",
"eventAttendanceMode": "https://schema.org/OnlineEventAttendanceMode",
"eventStatus": "https://schema.org/EventScheduled",
"location": {
"@type": "VirtualLocation",
"url": "https://example.com/conference"
},
"image": "https://example.com/conference.jpg",
"description": "加入我们的年度营销会议...",
"offers": {
"@type": "Offer",
"url": "https://example.com/conference/tickets",
"price": "199",
"priceCurrency": "USD",
"availability": "https://schema.org/InStock",
"validFrom": "2024-01-01"
},
"performer": {
"@type": "Organization",
"name": "示例公司"
},
"organizer": {
"@type": "Organization",
"name": "示例公司",
"url": "https://example.com"
}
}
一页上多个Schema类型
您可以(并且经常应该)拥有多个schema类型:
{
"@context": "https://schema.org",
"@graph": [
{
"@type": "Organization",
"@id": "https://example.com/#organization",
"name": "示例公司",
"url": "https://example.com"
},
{
"@type": "WebSite",
"@id": "https://example.com/#website",
"url": "https://example.com",
"name": "示例",
"publisher": {
"@id": "https://example.com/#organization"
}
},
{
"@type": "BreadcrumbList",
"itemListElement": [...]
}
]
}
验证和测试
工具
- Google富结果测试:https://search.google.com/test/rich-results
- Schema.org验证器:https://validator.schema.org/
- Search Console:增强功能报告
常见错误
缺少必需属性
- 查看Google文档了解必需字段
- 与schema.org最低要求不同
无效值
- 日期必须是ISO 8601格式
- URL必须完全限定
- 枚举必须使用精确值
与页面内容不匹配
- Schema不匹配可见内容
- 未显示评论的产品评级
- 价格不匹配显示价格
实现模式
静态网站
- 直接在HTML模板中添加JSON-LD
- 使用includes/partials用于可重用schema
动态网站(React、Next.js等)
- 渲染schema的组件
- 服务器端渲染用于SEO
- 序列化数据到JSON-LD
// Next.js示例
export default function ProductPage({ product }) {
const schema = {
"@context": "https://schema.org",
"@type": "Product",
name: product.name,
// ... 其他属性
};
return (
<>
<Head>
<script
type="application/ld+json"
dangerouslySetInnerHTML={{ __html: JSON.stringify(schema) }}
/>
</Head>
{/* 页面内容 */}
</>
);
}
CMS / WordPress
- 插件(Yoast、Rank Math、Schema Pro)
- 主题修改
- 自定义字段到结构化数据
输出格式
Schema实现
// 完整JSON-LD代码块
{
"@context": "https://schema.org",
"@type": "...",
// 完整标记
}
放置指令
添加代码的位置和方式
测试清单
- [ ] 在富结果测试中验证
- [ ] 无错误或警告
- [ ] 匹配页面内容
- [ ] 包含所有必需属性
需要询问的问题
如果您需要更多上下文:
- 这是什么类型的页面?
- 您希望实现哪些富结果?
- 有哪些数据可用于填充schema?
- 页面上有现有schema吗?
- 您的实现技术栈是什么?
相关技能
- seo-audit:用于包括schema审查的整体SEO
- programmatic-seo:用于大规模模板化schema
- analytics-tracking:用于测量富结果影响