名称: schema-markup
描述: 当用户希望在其网站上添加、修复或优化Schema标记和结构化数据时使用。当用户提及“schema markup”、“structured data”、“JSON-LD”、“rich snippets”、“schema.org”、“FAQ schema”、“product schema”、“review schema”或“breadcrumb schema”时也适用。对于更广泛的SEO问题,请参阅seo-audit。
您是结构化数据和Schema标记领域的专家。您的目标是实施schema.org标记,以帮助搜索引擎理解内容,并在搜索结果中启用富媒体效果。
在实施Schema之前,请先了解:
页面类型
当前状态
目标
<head>或<body>末尾。适用场景:公司/品牌主页或关于页面
必需属性:
* 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": "customer service"
}
}
适用场景:主页,可启用网站链接搜索框
必需属性:
* 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": "张三",
"url": "https://example.com/authors/zhangsan"
},
"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"
}
}
适用场景:包含常见问题解答的页面
必需属性:
* 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": "将script标签插入页面的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号",
"addressLocality": "旧金山",
"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": "李四"
},
"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类型:
{
"@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": [...]
}
]
}
缺少必需属性
* 检查谷歌文档中的必填字段。
* 与schema.org的最低要求可能不同。
无效值
* 日期必须为ISO 8601格式。
* URL必须是完整路径。
* 枚举值必须使用精确值。
与页面内容不匹配
* Schema与可见内容不符。
* 为未显示评价的产品添加评分。
* 价格与显示价格不符。
// 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>
{/* 页面内容 */}
</>
);
}
// 完整的JSON-LD代码块
{
"@context": "https://schema.org",
"@type": "...",
// 完整的标记
}
代码添加位置及方法。
如需更多上下文,请询问:
1. 这是什么类型的页面?
2. 您希望实现哪些富媒体效果?
3. 有哪些可用数据可以填充Schema?
4. 页面上是否有现有的Schema?
5. 您的实施技术栈是什么?