百度收录很蛋疼
在此之前用过@小康写的hexo-baidupush
很不错。
由于Bing和Google只爬sitemap.xml收录已经很快了,但总是爬sitemap.xml效率肯定没Api提交的快。
自己写了Bing的定时自动提交,目前还不支持Google定时自动提交,因为Google的API提交方式很鸡肋
Google indexing API有两个问题
账户安全密钥不能被泄露(谷歌只支持这种提交方式,对于没有后台的hexo来说是很致命的)
API提交只能使用json,而这个json格式只能包含一个网站url链接
不能多url放到一个json里,所以需要多次请求提交(baidu、bing、只需一次请求)
Google 最优提交方案是本地提交(能解决以上两个问题)
如果你有什么好的处理方案欢迎与我交流
正文
安装插件
COPY1 | npm i hexo-seo-autopush --save |
配置
在hexo 的config.yml里添加
hexo-seo-autopush配置
COPY1
2
3
4
5
6
7
8
9
10
11
12
13
14 | hexo_seo_autopush:
baidu:
enable:
count:
bing:
enable:
count:
google:
enable:
count:
google_file: |
添加Google Push
配置和解决push后没有GitHub Actions .github\workflows\AutoPush.yml
文件的问题
COPY1
2
3
4
5
6
7
8 | deploy:
- type:
repo:
branch:
ignore_hidden:
- type: |
获取站长平台密钥
Baidu Key
打开百度站长平台,点击左侧的普通收录https://ziyuan.baidu.com/

Bing Key
打开Bing站长平台,https://www.bing.com/webmasters/home
点击右上角头像 旁边的齿轮,跟着下图操作

Google Key
打开Google indexing API官网
选择创建项目,点击继续
点击转到凭据页面
跟着如下图片步骤




json文件内的内容
COPY1
2
3
4
5
6
7
8
9
10
11
12 | {
"type": ,
"project_id": ,
"private_key_id": ,
"private_key": ,
"client_email": ,
"client_id": ,
"auth_uri": ,
"token_uri": ,
"auth_provider_x509_cert_url": ,
"client_x509_cert_url":
} |
打开谷歌站长平台


配置博客仓库
Name必须是baidu_token
和bing_apikey
(不区分大小写)

添加完成后

谷歌的一些问题
触发谷歌提交的命令是hexo d
由于谷歌需要配合Google indexing API平台提供的json进行提交,而这个json格式不能泄露
为防止json泄露只能本地提交,将json放到hexo根目录可自定义重命名(必须对应插件的配置)
如果你的使用Github Actions自动部署的话请把仓库设置为私有

提交成功返回状态码
以上步骤完成后即可hexo d
部署了
看看Github仓库是否上传成功

点击Actions
查看是否执行

点击Auto Push
—->build
—–>点击第2步自动提交
如图43行

COPY1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 | {
"remain": ,
"success":
}
{
"ErrorCode": ,
"Message":
}
{"d":} |
Google 返回状态码
成功返回
COPY1
2
3
4
5
6
7
8
9
10 | Google response: {
urlNotificationMetadata: {
url: 'https:
latestUpdate: {
url: 'https:
type: 'URL_UPDATED',
notifyTime: 'T02::Z'
}
}
} |
出现此错误需要翻墙
COPY1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 | FetchError: request to https://www.googleapis.com/oauth2/v4/token failed, reason: connect ETIMEDOUT 172.217.27.138:443
at ClientRequest.<anonymous> (D:\Lete\GitHub\Hexo-Butterfly\node_modules\node-fetch\lib\index.js:1461:11)
at ClientRequest.emit (events.js:321:20)
at TLSSocket.socketErrorListener (_http_client.js:426:9)
at TLSSocket.emit (events.js:321:20)
at emitErrorNT (internal/streams/destroy.js:92:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
message: ,
: ,
errno: ,
code: ,
config: {
method: ,
url: ,
data: {
grant_type: ,
assertion: |
推荐本站淘宝优惠价购买喜欢的宝贝:
本文链接:https://www.hqytech.cn/post/9741.html 非本站原创文章欢迎转载,原创文章需保留本站地址!
打赏

微信支付宝扫一扫,打赏作者吧~