知识库首页 seo-llm 资料 metadata-guide.md

metadata guide

本地来源:seo-llm/skill/google-seo-skill/references/metadata-guide.md

元数据优化(Metadata)完整指南

1. 完整的 Metadata 配置

// app/layout.tsx
import { Metadata } from 'next'

export const metadata: Metadata = {
  // 基础信息
  title: {
    default: '网站名称 - 简短描述',
    template: '%s | 网站名称',
  },
  description: '网站的简洁描述,120-160 字符之间',

  // ⚠️ Google 搜索不使用 meta keywords 标签(官方明确声明),但其他搜索引擎可能使用
  keywords: ['关键词1', '关键词2', '关键词3'],

  // 作者信息
  authors: [{ name: '作者名称', url: 'https://example.com' }],

  // Open Graph (社交媒体分享)
  openGraph: {
    type: 'website',
    locale: 'zh_CN',
    url: 'https://example.com',
    siteName: '网站名称',
    title: '网站标题',
    description: '网站描述',
    images: [
      {
        url: 'https://example.com/og-image.jpg',
        width: 1200,
        height: 630,
        alt: 'Open Graph 图片描述',
      },
    ],
  },

  // Twitter Card
  twitter: {
    card: 'summary_large_image',
    site: '@username',
    creator: '@username',
    title: '标题',
    description: '描述',
    images: ['https://example.com/twitter-image.jpg'],
  },

  // 其他
  robots: {
    index: true,
    follow: true,
    googleBot: {
      index: true,
      follow: true,
      'max-video-preview': -1,
      'max-image-preview': 'large',
      'max-snippet': -1,
    },
  },

  // 验证
  verification: {
    google: 'google-site-verification-code',
    yandex: 'yandex-verification-code',
    bing: 'bing-verification-code',
  },
}

2. 页面级 Metadata

// app/blog/[slug]/page.tsx
export async function generateMetadata({ params }: PageProps): Promise<Metadata> {
  const post = await getPost(params.slug)

  return {
    title: post.title,
    description: post.excerpt,
    authors: [{ name: post.author.name }],

    openGraph: {
      title: post.title,
      description: post.excerpt,
      type: 'article',
      publishedTime: post.publishedAt,
      modifiedTime: post.updatedAt,
      authors: [post.author.name],
      images: [
        {
          url: post.coverImage,
          width: 1200,
          height: 630,
          alt: post.title,
        },
      ],
    },

    twitter: {
      card: 'summary_large_image',
      title: post.title,
      description: post.excerpt,
      images: [post.coverImage],
    },

    alternates: {
      canonical: `https://example.com/blog/${params.slug}`,
    },
  }
}

3. Favicon 要求

Google 搜索结果中会显示网站 Favicon,必须满足以下条件:

favicon_requirements:
  format: "正方形,推荐尺寸 ≥ 48x48px(Google 会缩放到 16x16)"
  access: "Favicon URL 必须允许 Googlebot 抓取(不被 robots.txt 阻止)"
  stability: "URL 应稳定,不频繁变更(Google 会缓存)"
  content: "能清晰代表网站品牌,不能是色情或仇恨内容"
  link_tag: '&lt;link rel=&quot;icon&quot; href=&quot;/favicon.ico&quot; /&gt; 或 &lt;link rel=&quot;icon&quot; type=&quot;image/png&quot; href=&quot;/favicon.png&quot; /&gt;'

4. 标题链接(Title Link)来源

Google 搜索结果中的标题链接从多个来源综合决定,并非只看 <title> 标签:

title_link_sources:
  primary: "<title> 标签内容"
  secondary:
    - "页面 <h1> 标签"
    - "og:title 属性"
    - "指向该页面的锚文本"
    - "WebSite Schema 的 name 字段"
  best_practices:
    - "title 简洁准确描述页面内容,不堆砌关键词"
    - "title 与 h1 保持一致(Google 不一致时可能替换标题)"
    - "不同页面使用不同 title(重复 title 导致 Google 自行选择)"
    - "过长标题会被截断,关键信息放前面"
    - "品牌名放在标题开头或末尾,用分隔符(-、|、:)分隔"
    - "title 语言/文字必须与页面主要内容语言一致"
    - "大型站点可使用程序化生成 meta description(确保各页独特且描述性)"

5. 搜索摘要控制

控制 Google 搜索结果中显示的摘要文本:

snippet_control:
  meta_robots:
    nosnippet: "完全不显示文字摘要"
    max-snippet: "限制摘要最大字符数,如 max-snippet:120"
  html_attribute:
    data-nosnippet: "为特定 HTML 元素添加,阻止该内容出现在摘要中"
  example: |
    &lt;meta name=&quot;robots&quot; content=&quot;max-snippet:150&quot; /&gt;
    <p data-nosnippet>此段落不会出现在搜索摘要中</p>

6. 署名日期(Publication Dates)

Google 搜索结果可能显示文章的发布或更新日期。关键规则:

publication_dates:
  methods:
    - "在页面醒目位置显示可见日期,使用清晰标签(如'发布日期:'、'最后更新:')"
    - "结构化数据中使用 datePublished 和 dateModified(ISO 8601 格式)"
  rules:
    - "可见日期与结构化数据日期必须一致"
    - "禁止使用未来日期"
    - "最小化页面中其他无关日期(如侧边栏日期),避免 Google 混淆"
    - "时区格式正确,考虑夏令时"
    - "禁止未经大幅更改就修改发布日期(Google 视为垃圾行为)"

7. Google 支持的 Meta 标签速查

supported_meta_tags:
  robots: "控制索引和抓取行为(index/noindex/follow/nofollow/none)"
  googlebot: "Google 专属的 robots 指令(可针对 googlebot-news 等子爬虫)"
  description: "页面摘要,可能显示在搜索结果中"
  viewport: "移动友好性信号"
  google-site-verification: "Search Console 所有权验证"
  notranslate: '&lt;meta name=&quot;googlebot&quot; content=&quot;notranslate&quot;&gt; — 阻止翻译'
  noimageindex: '&lt;meta name=&quot;robots&quot; content=&quot;noimageindex&quot;&gt; — 阻止页面图片被索引'
  nopagereadaloud: '&lt;meta name=&quot;google&quot; content=&quot;nopagereadaloud&quot;&gt; — 阻止朗读'
  rating: '&lt;meta name=&quot;rating&quot; content=&quot;adult&quot;&gt; — 标记成人内容'
  unavailable_after: '&lt;meta name=&quot;robots&quot; content=&quot;unavailable_after: 2025-12-31&quot;&gt; — 指定日期后从搜索结果中移除'
  indexifembedded: '&lt;meta name=&quot;robots&quot; content=&quot;noindex, indexifembedded&quot;&gt; — 即使 noindex,通过 iframe 嵌入时仍允许索引'
  x-robots-tag: "HTTP 头替代 robots meta(用于非 HTML 文件如 PDF)"
  data-nosnippet: "HTML 属性(仅限 <span>/<div>/<section>),排除特定元素出现在搜索摘要中"

8. 内容优化清单

### 标题优化
- [ ] 包含主关键词
- [ ] 长度 50-60 字符
- [ ] 吸引点击
- [ ] 准确描述内容

### 描述优化
- [ ] 包含关键词
- [ ] 长度 120-160 字符
- [ ] 包含行动号召
- [ ] 独特且吸引人

### 内容优化
- [ ] 主关键词出现在前 100 字
- [ ] 使用 H2、H3 标签组织内容
- [ ] 自然使用关键词(不堆砌)
- [ ] 包含相关关键词和同义词
- [ ] 内容长度 ≥ 1000 字(根据主题调整)
- [ ] 包含图片和多媒体
- [ ] 内部链接到相关内容
- [ ] 外部链接到权威来源

### 技术优化
- [ ] URL 简短、包含关键词
- [ ] 图片 alt 文本优化
- [ ] 页面加载速度 < 3 秒
- [ ] 移动端友好
- [ ] 添加结构化数据

相关文档

本文档为站内渲染。原始文件本地路径:saas/source/seo-llm/skill-google-seo-skill-references-metadata-guide-b235f7.md(仅本地保留,不入库不部署)