SEO
Command
/structured-data
生成页面的 JSON-LD 结构化数据
Install
$ npx -y skills add huifer/claude-code-seo --agent claude-codeHow it fires
How this command gets triggered: by you, by Claude, or both.
- Fires itselfClaude auto-loads it when your prompt matches the work.
- You can call itInvoke it directly when you want it.
- Slash command
/structured-data
Context preview
What this command does when you run it.
生成页面的 JSON-LD 结构化数据
Command definition
structured-data.mddescription: 生成页面的 JSON-LD 结构化数据
argument-hint: [page-path] [schema-type]
为指定页面生成合适的 JSON-LD 结构化数据。支持多种 Schema.org 类型,自动检测页面内容,提供 Next.js App Router 和 Pages Router 的实现代码。
功能
- ✅ 自动检测页面类型和内容
- ✅ 生成优化的 JSON-LD 结构化数据
- ✅ 支持 Next.js App Router 和 Pages Router
- ✅ 提供验证工具链接
- ✅ 包含必需和推荐字段
- ✅ 支持多种 Schema.org 类型
参数
- `$1` 或 `$ARGUMENTS`: 页面路径(必需)
- 文件路径或路由路径
- 示例:`app/blog/post-1/page.tsx`、`/blog/post-1`、`blog/post-1`
- `$2`: Schema.org 类型(可选)
- 如果不提供,自动检测
- 支持类型:Article, BlogPosting, NewsArticle, Product, Organization, LocalBusiness, WebPage, FAQPage, Review, Event, Person
支持的 Schema 类型
内容类型
**Article / BlogPosting**
- 博客文章和新闻
- 包含:headline, image, datePublished, author, publisher
**NewsArticle**
- 新闻文章
- 额外字段:dateModified, headline, articleSection
**TechArticle**
- 技术教程
- 额外字段:dependencies, proficiencyLevel
商业类型
**Product**
- 产品页面
- 包含:name, image, description, offers (price, availability)
**Organization**
- 组织/公司
- 包含:name, url, logo, address, contactPoint
**LocalBusiness**
- 本地商家
- 包含:address, telephone, openingHours, priceRange
页面类型
**WebPage**
- 普通网页
- 包含:name, description, url
**FAQPage**
- FAQ 页面
- 包含:Question 和 Answer 列表
互动类型
**Review**
- 评论
- 包含:itemReviewed, reviewRating, author
**AggregateRating**
- 聚合评分
- 包含:ratingValue, reviewCount, bestRating
使用示例
示例 1:博客文章(自动检测)
/structured-data app/blog/nextjs-seo-guide/page.tsx
输出:
# 结构化数据生成报告
## 页面分析
- 页面类型:博客文章
- 检测语言:中文
- 推荐类型:BlogPosting
- 标题:Next.js SEO 完全指南
- 作者:检测到或需要提供
## 生成的 JSON-LD
```json
{
"@context": "https://schema.org",
"@type": "BlogPosting",
"headline": "Next.js SEO 完全指南:从入门到精通",
"image": [
"https://yourdomain.com/images/blog/nextjs-seo-cover.jpg"
],
"datePublished": "2024-01-15T08:00:00+08:00",
"dateModified": "2024-01-15T08:00:00+08:00",
"author": {
"@type": "Person",
"name": "张三"
},
"publisher": {
"@type": "Organization",
"name": "YourBrand",
"logo": {
"@type": "ImageObject",
"url": "https://yourdomain.com/logo.png"
}
},
"description": "深入了解如何在 Next.js 项目中实现 SEO 优化。涵盖元数据、结构化数据、性能优化和最佳实践。",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "https://yourdomain.com/blog/nextjs-seo-guide"
}
}Next.js App Router 实现
将以下代码添加到 `app/blog/nextjs-seo-guide/page.tsx`:
const jsonLd = {
'@context': 'https://schema.org',
'@type': 'BlogPosting',
'headline': 'Next.js SEO 完全指南:从入门到精通',
'image': [
'https://yourdomain.com/images/blog/nextjs-seo-cover.jpg'
],
'datePublished': '2024-01-15T08:00:00+08:00',
'dateModified': '2024-01-15T08:00:00+08:00',
'author': {
'@type': 'Person',
'name': '张三'
},
'publisher': {
'@type': 'Organization',
'name': 'YourBrand',
'logo': {
'@type': 'ImageObject',
'url': 'https://yourdomain.com/logo.png'
}
},
'description': '深入了解如何在 Next.js 项目中实现 SEO 优化。涵盖元数据、结构化数据、性能优化和最佳实践。',
'mainEntityOfPage': {
'@type': 'WebPage',
'@id': 'https://yourdomain.com/blog/nextjs-seo-guide'
}
}
export default function Page() {
return (
<>
<script
type="application/ld+json"
dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}
/>
{/* 页面内容 */}
</>
)
}Next.js Pages Router 实现
将以下代码添加到 `pages/blog/nextjs-seo-guide.tsx`:
import Head from 'next/head'
export default function BlogPost() {
const jsonLd = {
'@context': 'https://schema.org',
'@type': 'BlogPosting',
'headline': 'Next.js SEO 完全指南:从入门到精通',
'image': [
'https://yourdomain.com/images/blog/nextjs-seo-cover.jpg'
],
'datePublished': '2024-01-15T08:00:00+08:00',
'dateModified': '2024-01-15T08:00:00+08:00',
'author': {
'@type': 'Person',
'name': '张三'
},
'publisher': {
'@type': 'Organization',
'name': 'YourBrand',
'logo': {
'@type': 'ImageObject',
'url': 'https://yourdomain.com/logo.png'
}
},
'description': '深入了解如何在 Next.js 项目中实现 SEO 优化。'
}
return (
<>
<Head>
<script
type="application/ld+json"
dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}
/>
</Head>
{/* 页面内容 */}
</>
)
}验证工具
使用以下工具验证你的结构化数据:
1. **Google Rich Results Test**
- URL: https://search.google.com/test/rich-results
- 粘贴你的 URL 或代码
2. **Schema Markup Validator**
- URL: https://validator.schema.org/
- 粘贴 JSON-LD 代码
3. **Google Search Console**
- 检查"增强"部分的结构化数据报告
优化建议
✅ 已包含必需字段 ✅ 图片 URL 完整 ✅ 日期格式正确(ISO 8601) ✅ 作者信息完整 ⚠️ 建议添加的字段:
- keywords(文章关键词)
- articleSection(文章分类)
- wordCount(字数)
需要我添加这些额外字段吗?
### 示例 2:产品页面
```bash
/structured-data products/plumbing-services Product
输出:
# Product 结构化数据
## JSON-LD 代码
```json
{
"@context": "https://schema.org",
"@type": "Product",
"name": "紧急管道维修服务",
"image": [
"https://yourdomain.com/images/products/plumbing-service.jpg"
],
"description": "24小时紧急管道维修服务,专业团队快速响应,覆盖旧金山湾区。",
"brand": {
"@type": "Brand",
"name": "SF Plumbing Services"
},
"offers": {
"@type": "Offer",
"url": "https://yourdomain.com/products/plumbing-services",
"priceCurrency": "USD",
"price": "150.00",
"priceValidUntil": "2024-12-31",
"availability": "https://schema.org/InStock",
"itemCondition": "https://schema.org/NewCondition"
},
"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": "4.8",
"reviewCount": "125"
}
}Next.js 实现
[代码示例...]
优化建议
✅ Product 必需字段完整 ✅ 价格信息清晰 ✅ 评分数据增强可信度 ⚠️ 考虑添加:
- reviews(详细评论列表)
- sku(产品 SKU)
- mpn(制造商零件号)
### 示例 3:FAQ 页面
```bash
/structured-data faq FAQPage
输出:
# FAQPage 结构化数据
## JSON-LD 代码
```json
{
"@context": "https://schema.org",
"@type": "FAQPage",
"mainEntity": [
{
"@type": "Question",
"name": "什么是紧急管道维修?",
"acceptedAnswer": {
"@type": "AnsweRead more
description: 生成页面的 JSON-LD 结构化数据 argument-hint: [page-path] [schema-type]
为指定页面生成合适的 JSON-LD 结构化数据。支持多种 Schema.org 类型,自动检测页面内容,提供 Next.js App Router 和 Pages Router 的实现代码。
功能
- ✅ 自动检测页面类型和内容
- ✅ 生成优化的 JSON-LD 结构化数据
- ✅ 支持 Next.js App Router 和 Pages Router
- ✅ 提供验证工具链接
- ✅ 包含必需和推荐字段
- ✅ 支持多种 Schema.org 类型
参数
- `$1` 或 `$ARGUMENTS`: 页面路径(必需)
- 文件路径或路由路径
- 示例:`app/blog/post-1/page.tsx`、`/blog/post-1`、`blog/post-1`
- `$2`: Schema.org 类型(可选)
- 如果不提供,自动检测
- 支持类型:Article, BlogPosting, NewsArticle, Product, Organization, LocalBusiness, WebPage, FAQPage, Review, Event, Person
支持的 Schema 类型
内容类型
**Article / BlogPosting**
- 博客文章和新闻
- 包含:headline, image, datePublished, author, publisher
**NewsArticle**
- 新闻文章
- 额外字段:dateModified, headline, articleSection
**TechArticle**
- 技术教程
- 额外字段:dependencies, proficiencyLevel
商业类型
**Product**
- 产品页面
- 包含:name, image, description, offers (price, availability)
**Organization**
- 组织/公司
- 包含:name, url, logo, address, contactPoint
**LocalBusiness**
- 本地商家
- 包含:address, telephone, openingHours, priceRange
页面类型
**WebPage**
- 普通网页
- 包含:name, description, url
**FAQPage**
- FAQ 页面
- 包含:Question 和 Answer 列表
互动类型
**Review**
- 评论
- 包含:itemReviewed, reviewRating, author
**AggregateRating**
- 聚合评分
- 包含:ratingValue, reviewCount, bestRating
使用示例
示例 1:博客文章(自动检测)
/structured-data app/blog/nextjs-seo-guide/page.tsx
输出:
# 结构化数据生成报告
## 页面分析
- 页面类型:博客文章
- 检测语言:中文
- 推荐类型:BlogPosting
- 标题:Next.js SEO 完全指南
- 作者:检测到或需要提供
## 生成的 JSON-LD
```json
{
"@context": "https://schema.org",
"@type": "BlogPosting",
"headline": "Next.js SEO 完全指南:从入门到精通",
"image": [
"https://yourdomain.com/images/blog/nextjs-seo-cover.jpg"
],
"datePublished": "2024-01-15T08:00:00+08:00",
"dateModified": "2024-01-15T08:00:00+08:00",
"author": {
"@type": "Person",
"name": "张三"
},
"publisher": {
"@type": "Organization",
"name": "YourBrand",
"logo": {
"@type": "ImageObject",
"url": "https://yourdomain.com/logo.png"
}
},
"description": "深入了解如何在 Next.js 项目中实现 SEO 优化。涵盖元数据、结构化数据、性能优化和最佳实践。",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "https://yourdomain.com/blog/nextjs-seo-guide"
}
}Next.js App Router 实现
将以下代码添加到 `app/blog/nextjs-seo-guide/page.tsx`:
const jsonLd = {
'@context': 'https://schema.org',
'@type': 'BlogPosting',
'headline': 'Next.js SEO 完全指南:从入门到精通',
'image': [
'https://yourdomain.com/images/blog/nextjs-seo-cover.jpg'
],
'datePublished': '2024-01-15T08:00:00+08:00',
'dateModified': '2024-01-15T08:00:00+08:00',
'author': {
'@type': 'Person',
'name': '张三'
},
'publisher': {
'@type': 'Organization',
'name': 'YourBrand',
'logo': {
'@type': 'ImageObject',
'url': 'https://yourdomain.com/logo.png'
}
},
'description': '深入了解如何在 Next.js 项目中实现 SEO 优化。涵盖元数据、结构化数据、性能优化和最佳实践。',
'mainEntityOfPage': {
'@type': 'WebPage',
'@id': 'https://yourdomain.com/blog/nextjs-seo-guide'
}
}
export default function Page() {
return (
<>
<script
type="application/ld+json"
dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}
/>
{/* 页面内容 */}
</>
)
}Next.js Pages Router 实现
将以下代码添加到 `pages/blog/nextjs-seo-guide.tsx`:
import Head from 'next/head'
export default function BlogPost() {
const jsonLd = {
'@context': 'https://schema.org',
'@type': 'BlogPosting',
'headline': 'Next.js SEO 完全指南:从入门到精通',
'image': [
'https://yourdomain.com/images/blog/nextjs-seo-cover.jpg'
],
'datePublished': '2024-01-15T08:00:00+08:00',
'dateModified': '2024-01-15T08:00:00+08:00',
'author': {
'@type': 'Person',
'name': '张三'
},
'publisher': {
'@type': 'Organization',
'name': 'YourBrand',
'logo': {
'@type': 'ImageObject',
'url': 'https://yourdomain.com/logo.png'
}
},
'description': '深入了解如何在 Next.js 项目中实现 SEO 优化。'
}
return (
<>
<Head>
<script
type="application/ld+json"
dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}
/>
</Head>
{/* 页面内容 */}
</>
)
}验证工具
使用以下工具验证你的结构化数据:
1. **Google Rich Results Test**
- URL: https://search.google.com/test/rich-results
- 粘贴你的 URL 或代码
2. **Schema Markup Validator**
- URL: https://validator.schema.org/
- 粘贴 JSON-LD 代码
3. **Google Search Console**
- 检查"增强"部分的结构化数据报告
优化建议
✅ 已包含必需字段 ✅ 图片 URL 完整 ✅ 日期格式正确(ISO 8601) ✅ 作者信息完整 ⚠️ 建议添加的字段:
- keywords(文章关键词)
- articleSection(文章分类)
- wordCount(字数)
需要我添加这些额外字段吗?
### 示例 2:产品页面 ```bash /structured-data products/plumbing-services Product
输出:
# Product 结构化数据
## JSON-LD 代码
```json
{
"@context": "https://schema.org",
"@type": "Product",
"name": "紧急管道维修服务",
"image": [
"https://yourdomain.com/images/products/plumbing-service.jpg"
],
"description": "24小时紧急管道维修服务,专业团队快速响应,覆盖旧金山湾区。",
"brand": {
"@type": "Brand",
"name": "SF Plumbing Services"
},
"offers": {
"@type": "Offer",
"url": "https://yourdomain.com/products/plumbing-services",
"priceCurrency": "USD",
"price": "150.00",
"priceValidUntil": "2024-12-31",
"availability": "https://schema.org/InStock",
"itemCondition": "https://schema.org/NewCondition"
},
"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": "4.8",
"reviewCount": "125"
}
}Next.js 实现
[代码示例...]
优化建议
✅ Product 必需字段完整 ✅ 价格信息清晰 ✅ 评分数据增强可信度 ⚠️ 考虑添加:
- reviews(详细评论列表)
- sku(产品 SKU)
- mpn(制造商零件号)
### 示例 3:FAQ 页面 ```bash /structured-data faq FAQPage
输出:
# FAQPage 结构化数据
## JSON-LD 代码
```json
{
"@context": "https://schema.org",
"@type": "FAQPage",
"mainEntity": [
{
"@type": "Question",
"name": "什么是紧急管道维修?",
"acceptedAnswer": {
"@type": "Answe Stats
111
Stars
5
Forks
Quiet
Maintenance
HTML
Language
MIT
License
9mo ago
Last commit
9mo ago
Created
5h ago
Added
Other commands on claude-seo-assistant.
Command
Command
Command
Command
Command
Command

