> ## Documentation Index
> Fetch the complete documentation index at: https://omer-914cc1c6.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# SEO（搜索引擎优化）

> 面向更佳搜索可见性的 SEO 最佳实践与 meta 标签配置

Mintlify 会自动处理多项 SEO 最佳实践，包括：

* 生成 meta 标签
* 生成站点地图和 `robots.txt` 文件
* 语义化 HTML 结构
* 移动端优化

你可以在 `docs.json` 或页面的 frontmatter 中添加 `metatags` 字段，来自定义站点的 meta 标签。

<div id="global-meta-tags">
  ## 全局 meta 标签
</div>

你可以在 `docs.json` 中添加 `metadata` 字段来设置默认的 meta 标签。

```json theme={null}
"seo": {
    "metatags": {
        "og:image": "您的默认元标签图片链接"
    }
}
```

<div id="page-specific-meta-tags">
  ## 页面特定的 meta 标签
</div>

将你的 meta 标签添加到页面的 metadata 中，如下所示：

```mdx theme={null}
---
title: '您的示例页面标题'
'og:image': '您的元标签图片链接'
---
```

<Warning>
  将带有冒号的 Meta 标签写入页面的 metadata 时，需要用引号将其包裹起来。
</Warning>

<div id="common-meta-tags-reference">
  ## 常用 meta 标签参考
</div>

下面是可添加到你的 `docs.json` 中的 meta 标签完整列表。这些标签有助于提升站点的 SEO（搜索引擎优化）、社交分享效果和浏览器兼容性。

你可以使用 [metatags.io](https://metatags.io/) 预览这些 meta 标签在不同平台上的呈现方式。

```json expandable theme={null}
"seo": {
    "metatags": {
      "robots": "noindex",
      "charset": "UTF-8",
      "viewport": "width=device-width, initial-scale=1.0",
      "description": "页面描述",
      "keywords": "关键词1, 关键词2, 关键词3",
      "author": "作者姓名",
      "robots": "index, follow",
      "googlebot": "index, follow",
      "google": "notranslate",
      "google-site-verification": "verification_token",
      "generator": "Mintlify",
      "theme-color": "#000000",
      "color-scheme": "light dark",
      "canonical": "https://your-custom-domain-here.com",
      "format-detection": "telephone=no",
      "referrer": "origin",
      "refresh": "30",
      "rating": "general",
      "revisit-after": "7 days",
      "language": "en",
      "copyright": "版权所有 2024",
      "reply-to": "email@example.com",
      "distribution": "global",
      "coverage": "全球",
      "category": "技术",
      "target": "all",
      "HandheldFriendly": "True",
      "MobileOptimized": "320",
      "apple-mobile-web-app-capable": "yes",
      "apple-mobile-web-app-status-bar-style": "black",
      "apple-mobile-web-app-title": "应用标题",
      "application-name": "应用名称",
      "msapplication-TileColor": "#000000",
      "msapplication-TileImage": "path/to/tile.png",
      "msapplication-config": "path/to/browserconfig.xml",
      "og:title": "Open Graph 标题",
      "og:type": "website",
      "og:url": "https://example.com",
      "og:image": "https://example.com/image.jpg",
      "og:description": "Open Graph 描述",
      "og:site_name": "网站名称",
      "og:locale": "en_US",
      "og:video": "https://example.com/video.mp4",
      "og:audio": "https://example.com/audio.mp3",
      "twitter:card": "summary",
      "twitter:site": "@username",
      "twitter:creator": "@username",
      "twitter:title": "Twitter 标题",
      "twitter:description": "Twitter 描述",
      "twitter:image": "https://example.com/image.jpg",
      "twitter:image:alt": "图片描述",
      "twitter:player": "https://example.com/player",
      "twitter:player:width": "480",
      "twitter:player:height": "480",
      "twitter:app:name:iphone": "应用名称",
      "twitter:app:id:iphone": "12345",
      "twitter:app:url:iphone": "app://",
      "article:published_time": "2024-01-01T00:00:00+00:00",
      "article:modified_time": "2024-01-02T00:00:00+00:00",
      "article:expiration_time": "2024-12-31T00:00:00+00:00",
      "article:author": "作者姓名",
      "article:section": "技术",
      "article:tag": "标签1, 标签2, 标签3",
      "book:author": "作者姓名",
      "book:isbn": "1234567890",
      "book:release_date": "2024-01-01",
      "book:tag": "标签1, 标签2, 标签3",
      "profile:first_name": "John",
      "profile:last_name": "Doe",
      "profile:username": "johndoe",
      "profile:gender": "male",
      "music:duration": "205",
      "music:album": "专辑名称",
      "music:album:disc": "1",
      "music:album:track": "1",
      "music:musician": "艺术家姓名",
      "music:song": "歌曲名称",
      "music:song:disc": "1",
      "music:song:track": "1",
      "video:actor": "演员姓名",
      "video:actor:role": "角色名称",
      "video:director": "导演姓名",
      "video:writer": "编剧姓名",
      "video:duration": "120",
      "video:release_date": "2024-01-01",
      "video:tag": "标签1, 标签2, 标签3",
      "video:series": "系列名称"
  }
}
```

<div id="sitemaps-and-robotstxt-files">
  ## 站点地图与 robots.txt 文件
</div>

Mintlify 会自动生成 `sitemap.xml` 和 `robots.txt` 文件。你可以在文档站点的 URL 末尾追加 `/sitemap.xml` 来查看站点地图。

默认情况下，仅 `docs.json` 中列出的页面会被包含。若要将隐藏链接也纳入其中，请在 `docs.json` 中添加 `seo.indexing`：

```json theme={null}
"seo": {
    "indexing": `all`
}
```

<div id="custom-sitemaps-and-robotstxt-files">
  ### 自定义 sitemap 和 robots.txt 文件
</div>

要添加自定义的 `sitemap.xml` 或 `robots.txt` 文件，请在项目根目录创建相应的 `sitemap.xml` 或 `robots.txt` 文件。添加自定义文件会覆盖同名的自动生成文件。删除自定义文件后，将恢复使用默认文件。

<div id="disabling-indexing">
  ## 禁用索引编入
</div>

如果你想阻止某个页面被搜索引擎收录，可以在该页面的 [frontmatter](zh/pages) 中添加以下内容：

```
---
noindex: true
---
```

你也可以在 `docs.json` 中将 `metadata.robots` 字段设置为 `"noindex"`，为文档中的所有页面指定 `noindex`：

```json theme={null}
"seo": {
    "metatags": {
      "robots": "noindex"
    }
  }
```

<div id="seo-best-practices">
  ## SEO 最佳实践
</div>

<AccordionGroup>
  <Accordion title="撰写具有描述性的标题与说明">
    * 使用清晰、具有描述性的页面标题（50–60 个字符）
    * 撰写具有吸引力的说明（150–160 个字符）
    * 包含相关关键词
    * 确保每个页面的标题和说明都独一无二
  </Accordion>

  <Accordion title="优化内容结构">
    * 使用正确的标题层级（H1 → H2 → H3）
    * 优先为人而写，其次再考虑搜索引擎
    * 在标题和正文中包含相关关键词
    * 保持 URL 简洁、具描述性，并按层级组织
    * 用小标题和列表拆分长篇内容
  </Accordion>

  <Accordion title="内部链接策略">
    * 在文档中链接到相关页面
    * 使用描述性的锚文本，而非“click here”
    * 通过链接相关概念创建主题集群
    * 使用自动交叉引用功能
  </Accordion>

  <Accordion title="图片 SEO">
    * 为图片使用具有描述性的文件名
    * 始终为无障碍与 SEO 添加 alt 文本
    * 优化图片文件大小以提升加载速度
    * 使用与内容相关、能起到支撑作用的图片
  </Accordion>
</AccordionGroup>
