Hugo

Bing IndexNow 快速收录站点

警告
本文最后更新于 2026-02-08,文中内容可能已过时。

默认已部署且绑定域名,详见《Hugo 博客自动化部署指南》和《Hugo 自定义域名配置指南》。

IndexNow 是由 Bing 主导的一种主动提交协议,用来在页面新增、更新或删除时,实时通知搜索引擎抓取指定 URL,而不是被动等待爬虫轮询。

操作流程
操作流程

下面介绍 GitHub Actions 的配置方法,以及一个基于 IndexNow 和 Cloudflare Crawler Hints 的爬虫加速方案,用于从 sitemap.xml 自动检测更新页面并主动通知搜索引擎。1

生成 API 密钥

打开 必应站长工具,点击 网站地图,提交站点地图(如 https://example.com/sitemap.xml)。

打开 IndexNow 页面,点击 Generate API Key 生成并下载 API Key(如 abcdef123456789.txt)。

将下载的 .txt 密钥文件复制到项目根目录,部署后通过浏览器访问 https://example.com/abcdef123456789.txt,页面应仅显示密钥字符串本身,无其他字符。

使用正确的格式构造请求,如:

Plaintext
1
https://api.indexnow.org/IndexNow?url=https://example.com/posts/某篇文章/&key=abcdef123456789

请求成功后,必应站长工具的 IndexNow 会显示该 URL。

创建仓库密钥

打开 GitHub 仓库,点击 Settings > Secret and variables > Actions,创建 Repository secrets:

  • INDEXNOW_KEY:如 abcdef123456789
  • INDEXNOW_KEY_LOCATION:如 https://example.com/abcdef123456789.txt

创建工作流

运行以下命令,创建工作流文件:

Bash
1
2
mkdir -p .github/workflows
touch .github/workflows/indexnow.yaml

修改以下文件(记得修改 sitemap-location):

YAML.github/workflows/indexnow.yaml
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
name: "IndexNow"
on:
  push:
    branches:
      - main
  schedule:
    - cron: "0 0,12 * * *" # 每日两次推送

jobs:
  check-and-submit:
    runs-on: ubuntu-latest
    steps:
      - name: indexnow-action
        uses: bojieyang/indexnow-action@v2
        with:
          sitemap-location: "https://example.com/sitemap.xml"
          endpoint: "www.bing.com"
          since: 1
          since-unit: "day" # 可选: minute, hour, day, week, month, year
          limit: 100
          key: ${{ secrets.INDEXNOW_KEY }}
          key-location: ${{ secrets.INDEXNOW_KEY_LOCATION }}

完成后,推送到部署平台即可。

开启 Crawler Hints

打开 Cloudflare,点击 ,选择域名,点击 缓存 > 配置,开启 Crawler Hints,该功能由 Cloudflare 根据流量模式分析判断内容可能已更新,并向搜索引擎发送更新提示。

留言交流