Hexo 站点的SEO配置

Hexo 站点的SEO配置
Hexo Blog 配置SEO主要用到两个插件hexo-generator-sitemap,hexo-submit-urls-to-search-engine

重要步骤

  1. Google账号的话激活Google Cloud
    1. 根据文档步骤完成服务账号创建密钥创建
    2. 密钥创建成功后下载密钥的json文件到hexo根目录下,并在_config.yml中配置
  2. https://www.google.com/webmasters/verification/home
    1. 会自动跳到新后台,使用『网址前缀』方式验证所有权,会生成googleaXXXXXX.html 文件
    2. download 下载到hexo 的source目录下
    3. 完成站点验证
  3. 登录https://search.google.com/search-console
    1. 在『设置』-> 『用户和权限』 ->『添加用户』 将密钥json文件中的client_email中邮箱(就是第一步在Google中创建的服务账号对应的邮箱)添加
    2. 指定权限为所拥有者

代码

1
2
3
npm install hexo-submit-urls-to-search-engine --save
npm install hexo-generator-sitemap --save

Config 配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
hexo_submit_urls_to_search_engine:
submit_condition: count #链接被提交的条件,可选值:count | period 现仅支持count
count: 10 # 提交最新的10个链接
period: 900 # 提交修改时间在 900 秒内的链接
google: 1 # 是否向Google提交,可选值:1 | 0(0:否;1:是)
bing: 0 # 是否向bing提交,可选值:1 | 0(0:否;1:是)
baidu: 0 # 是否向baidu提交,可选值:1 | 0(0:否;1:是)
txt_path: submit_urls.txt # 文本文档名, 需要推送的链接会保存在此文本文档里
baidu_host: https://konbluesky.github.io # 在百度站长平台中注册的域名
baidu_token: #请按照文档说明获取 # 请注意这是您的秘钥, 所以请不要把它直接发布在公众仓库里!
bing_host: https://konbluesky.github.io # 在bing站长平台中注册的域名
bing_enable_indexnow: false # 是否用 indexNow 提交链接给必应: true (Yes) | false (No). 只有 2.1.1 及之后的版本才可以开启这个功能。
bing_token: #请按照文档说明获取 # 请注意这是您的秘钥, 所以请不要把它直接发布在公众仓库里!
google_host: https://konbluesky.github.io # 在google站长平台中注册的域名
google_key_file: key.json #存放google key的json文件,放于网站根目录(与hexo _config.yml文件位置相同),请不要把json文件内容直接发布在公众仓库里!
google_proxy: 0
replace: 0 # 是否替换链接中的部分字符串,可选值:1 | 0(0:否;1:是)
find_what: http://konbluesky.github.io

推送成功

1
2
3
4
5
6
7
8
Google response:  {
urlNotificationMetadata: {
url: 'https://konbluesky.github.io/2024/11/27/hummingbot_gateway/'
}
}
Google response: {
urlNotificationMetadata: { url: 'https://konbluesky.github.io/2025/01/14/python_py_spy/' }
}

问题处理

1
2
3
4
5
6
7
Google response:  {
error: {
code: 403,
message: 'Permission denied. Failed to verify the URL ownership.',
status: 'PERMISSION_DENIED'
}
}

参考文档

  1. https://github.com/cjh0613/hexo-submit-urls-to-search-engine

    插件github地址

  2. https://cjh0613.com/20200603HexoSubmitUrlsToSearchEngine

    hexo-submit-urls-to-search-engine 插件使用说明
    !! Indexing API 允许网站所有者在发布招聘信息或直播时直接通知 Google 添加或删除视频页面。这允许 Google 安排页面进行新的抓取, 可以带来更高质量的用户流量。Indexing API 只能用于抓取具有以下特征的页面: JobPosting 或 嵌入在 VideoObject 中的 BroadcastEvent 。对于包含许多短期页面(例如招聘信息或直播视频)的网站,Indexing API 允许单独推送更新,从而使搜索结果中的内容保持最新。

  3. https://github.com/hexojs/hexo-generator-sitemap

    用来生成sitemap.xml 文件

  4. https://developers.google.cn/search/apis/indexing-api/v3/prereqs
  5. https://zhuanlan.zhihu.com/p/651590960
作者

Gavin

发布于

2025-05-12

更新于

2025-05-13

许可协议

评论