一键导入
nextjs-metadata
Next.js Metadata API for SEO, OpenGraph tags, structured data, and social sharing. Use when implementing metadata, SEO, or social media previews.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Next.js Metadata API for SEO, OpenGraph tags, structured data, and social sharing. Use when implementing metadata, SEO, or social media previews.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Automatically discover and install relevant skills from SkillsMP and other sources
Go error handling patterns including wrapping, custom error types, errors.Is/As, and error conventions. Use when handling, creating, or checking errors in Go.
Go performance optimizations including memory allocation reduction, efficient string building, I/O operations, and resource pooling. Use when optimizing Go code for speed or memory efficiency.
Go testing best practices including table-driven tests, race detection, test coverage, and mocking strategies. Use when writing or reviewing Go tests.
GraphQL resolver patterns including dataloader for N+1 prevention, context propagation, authorization, error handling, and validation. Use when implementing GraphQL resolvers.
GraphQL schema design including types, fields, pagination, nullability, naming conventions, and descriptions. Use when designing or modifying GraphQL schemas.
| name | nextjs-metadata |
| description | Next.js Metadata API for SEO, OpenGraph tags, structured data, and social sharing. Use when implementing metadata, SEO, or social media previews. |
Expert guidance for implementing effective metadata in Next.js.
| Concern | Solution | Example |
|---|---|---|
| Page title | metadata object | export const metadata = { title: '...' } |
| Dynamic metadata | generateMetadata function | export async function generateMetadata({ params }) |
| OpenGraph images | metadata.images | openGraph: { images: ['/og.jpg'] } |
| Structured data | Script component | <Script type="application/ld+json"> |
| Canonical URLs | metadata.alternates | canonical: 'https://...' |
| Twitter cards | metadata.twitter | twitter: { card: 'summary_large_image' } |
Specify a number or describe your metadata scenario.
| Response | Reference to Read |
|---|---|
| 1, "static", "metadata", "object" | static-metadata.md |
| 2, "dynamic", "generatemetadata", "params" | dynamic-metadata.md |
| 3, "opengraph", "social", "sharing" | opengraph.md |
| 4, "structured", "json-ld", "schema" | structured-data.md |
| 5, "canonical", "seo", "duplicate" | seo.md |
Every page needs metadata: Title, description, OpenGraph image minimum.
Static for static pages: Use metadata object when values don't change.
Dynamic for dynamic routes: Use generateMetadata when data comes from params or fetch.
OpenGraph for sharing: Ensure pages look good when shared on social media.
Structured data for rich results: Use JSON-LD for articles, products, organizations.
// app/page.tsx
import { Metadata } from 'next'
export const metadata: Metadata = {
title: 'My App',
description: 'Description for search engines',
openGraph: {
title: 'My App',
description: 'Description for social sharing',
images: ['/og-image.jpg'],
},
}
export default function Page() {
return <div>...</div>
}
// app/blog/[slug]/page.tsx
import { Metadata } from 'next'
export async function generateMetadata(
{ params }: { params: { slug: string } }
): Promise<Metadata> {
const post = await fetchPost(params.slug)
return {
title: post.title,
description: post.excerpt,
openGraph: {
title: post.title,
images: [post.ogImage],
},
}
}
export default function BlogPost({ params }: { params: { slug: string } }) {
// ...
}
import Script from 'next/script'
export default function ArticlePage({ post }: { post: Post }) {
const jsonLd = {
'@context': 'https://schema.org',
'@type': 'Article',
headline: post.title,
datePublished: post.publishedAt,
author: { '@type': 'Person', name: post.author.name },
}
return (
<>
<Script type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }} />
<article>{post.content}</article>
</>
)
}
| Element | Required | Format |
|---|---|---|
| title | Yes | string or Metadata.title |
| description | Yes | string (~160 chars) |
| openGraph:title | Yes | string |
| openGraph:description | Yes | string |
| openGraph:image | Yes | string or array (1200x630px min) |
| twitter:card | Recommended | 'summary_large_image' |
| canonical | Recommended | string |
| alternates:languages | Optional | Record<locale, string> |
| Issue | Severity | Fix |
|---|---|---|
| Missing page title | High | Add metadata.title |
| No OpenGraph image | Medium | Add openGraph.images |
| No description | Medium | Add metadata.description |
| Dynamic not using generateMetadata | High | Change to async function |
| Duplicate content (no canonical) | Medium | Add metadata.canonical |
| Small OG image (< 1200x630) | Low | Use larger image |
| File | Topics |
|---|---|
| static-metadata.md | metadata object, all options |
| dynamic-metadata.md | generateMetadata, params, fetch |
| opengraph.md | OG tags, Twitter cards, images |
| structured-data.md | JSON-LD, Script component, schemas |
| seo.md | Canonical, hreflang, robots, sitemap |
Metadata is complete when: