--- sidebar_position: 8 title: SEO 策略 sidebar_label: SEO description: Plaza 的 SEO 架构、Open Graph 规范、sitemap 生成、静态化策略和爬虫优化 --- # SEO 策略 > **权威文档**:本页是 Plaza 所有 HTML meta、Open Graph、JSON-LD、robots 规范的唯一来源;[03-frontend](./03-frontend) 通过 `lib/metadata.ts` 引用此处约定。 ## 核心目标 - 广场每个帖子、每个分类页、每个用户主页都能被搜索引擎完整收录。 - 微信/微博/钉钉等社交平台分享时展示封面图、标题和摘要。 - 新帖发布后 24 小时内可被 Googlebot 和百度蜘蛛发现。 --- ## 渲染策略 | 页面 | 渲染方式 | 缓存策略 | 说明 | | --- | --- | --- | --- | | /plaza 首页 | SSR(`force-dynamic`) | `fetch` revalidate 60s + Redis Feed 缓存 | 服务端每次渲染,API 层缓存热门列表 | | /plaza/cat/:slug 分类 | SSR(`force-dynamic`) | `fetch` revalidate 300s | 分类元数据预生成 `generateStaticParams` | | /plaza/p/:id 帖子详情 | SSR(`force-dynamic`) | `no-store` | 互动数实时显示 | | /u/:slug 用户主页 | SSR | `revalidate: 300` | 5 分钟 ISR | | 404 页面 | 静态 | - | Next.js 默认 | **说明**:Plaza 首页/分类页使用 `dynamic = 'force-dynamic'`,通过 `lib/api.ts` 的 `next.revalidate` 控制上游 API 缓存,而非 Next.js 页面级 ISR。用户主页保留 `revalidate: 300`。加载态使用 `loading.tsx` + `PostGridSkeleton`。 --- ## HTML meta 规范 ### 帖子详情页(最重要) ```typescript // app/plaza/p/[id]/page.tsx export async function generateMetadata({ params }: { params: { id: string } }): Promise { const post = await fetchPost(params.id); if (!post) { return { title: 'Page Not Found' }; } const url = `https://go.tkmind.cn/plaza/p/${post.id}`; const image = post.cover_url || 'https://go.tkmind.cn/og-default.png'; return { title: `${post.title} - Plaza | MindSpace`, description: post.summary || `${post.author.display_name} 用 MindSpace 创作的作品`, keywords: post.tags.join(', '), // Open Graph(微信、Facebook、钉钉) openGraph: { title: post.title, description: post.summary, url, siteName: 'MindSpace Plaza', images: [ { url: image, width: 1200, height: 630, alt: post.title, }, ], type: 'article', publishedTime: post.published_at, authors: [`https://go.tkmind.cn/u/${post.author.slug}`], tags: post.tags, }, // Twitter Card(X / 微博) twitter: { card: 'summary_large_image', title: post.title, description: post.summary, images: [image], creator: `@${post.author.slug}`, }, // 规范 URL(防止重复内容) alternates: { canonical: url, }, // 爬虫指令 robots: { index: true, follow: true, }, }; } ``` ### 用户主页 ```typescript openGraph: { type: 'profile', firstName: user.display_name, username: user.slug, images: [{ url: user.avatar_url, width: 400, height: 400 }], } ``` ### 广场首页 ```typescript openGraph: { type: 'website', title: 'Plaza - 发现 AI 创作的精彩内容', description: '浏览来自全球用户用 MindSpace 创作的报告、作品和页面', images: [{ url: 'https://go.tkmind.cn/plaza-og.png', width: 1200, height: 630 }], } ``` --- ## 结构化数据(JSON-LD) 帖子详情页在 `` 中注入 Article Schema: ```typescript // app/plaza/p/[id]/page.tsx export default async function PostPage({ params }) { const post = await fetchPost(params.id); const jsonLd = { '@context': 'https://schema.org', '@type': 'Article', headline: post.title, description: post.summary, image: post.cover_url, datePublished: post.published_at, author: { '@type': 'Person', name: post.author.display_name, url: `https://go.tkmind.cn/u/${post.author.slug}`, }, publisher: { '@type': 'Organization', name: 'MindSpace', logo: { '@type': 'ImageObject', url: 'https://go.tkmind.cn/logo.png', }, }, }; return ( <>