抱歉,您的浏览器无法访问本站
本页面需要浏览器支持(启用)JavaScript
了解详情 >

安装cnpm,用了魔法的人不用,没用的要安下。

1
npm install -g cnpm --registry=https://registry.npmmirror.com

安装hexo-abbrlink2生成永久固定链接(更新:也可以使用其他的,如我正在用hexo-friendly-link,这个更简单,所以也很稳定),也用过hexo-translate-title,但是安装有点麻烦,作用是把形如
https://xiuxi1.github.io/2023/06/18/将博客内容推送到搜索引擎
变成形如
https://xiuxi1.github.io/posts/3/
以便搜索引擎抓取,进行SEO优化

1
cnpm install hexo-abbrlink2 --save

注意修改 config.yml 文件中的permalink:

1
permalink: ':year/:month/:day/:title/'

修改为

1
2
3
permalink: posts/:abbrlink/
abbrlink:
start: 0 # the first id, default 0

安装sitemap生成器

1
cnpm install hexo-generator-sitemap --save

登陆必应站长平台
添加网站,如https://xiuxi1.github.io/
会有个验证,把下载下来的BingSiteAuth.xml放在blog\source文件夹就好,记得部署,即hexo clean & hexo g & hexo d
可以按照提示把sitemap上传,一般链接是https://xiuxi1.github.io/sitemap.xml
其余的网址提交(URL Submission)、索引现在(IndexNow),……,都可以按照提示自己弄,特别是IndexNow,可以实时更新。
可以用python写个IndexNow推送程序,如

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import requests
urls = []
print('请输入URL,输入0结束:')
while True:
url = input()
if url == '0':
break
urls.append(url)

for url in urls:
try:
urll=r'https://www.bing.com/indexnow?url=【https://xiuxi1.github.io/】'+url+ r'/&key=【在IndexNow中生成的key(注意那个文件要放进source)】'
response = requests.get(urll)
if response.status_code == 200:
print(urll, '{200: 成功}')
elif response.status_code == 400:
print(urll, '{400: 格式无效}')
elif response.status_code == 403:
print(urll, '{403: 密匙无效}')
elif response.status_code == 422:
print(urll, '{422: URL或密匙不匹配}')
elif response.status_code == 429:
print(urll, '{429: 请求过多}')
except Exception as e:
print(urll, '{错误:', e, '}')

写个bat程序,点击即执行这个python程序

1
2
3
call 【D:\ana\Scripts\activate.bat】 【D:\ana】
call python 【E:\Desktop\update.py】
pause

此外,还可以使用hexo-submit-urls-to-search-engine,但有点麻烦,主要是怕密匙泄露,想弄这个的可以试试。

评论