博客搭好顺便折腾了一下SEO,这里记录一下优化用到的插件和相关配置。
永久链接 hexo-abbrlink
- 用途:
hexo 默认是以文件名作为链接对搜索引擎不友好,使用这个插件可以生成永久链接,方便搜索引擎收录 - 安装:
pnpm install hexo-abbrlink --save - 配置: 在
_config.yml中修改配置
1 2 3 4 5 6 7
| permalink: posts/:abbrlink.html
abbrlink: alg: crc32 rep: hex
|
站点地图 hexo-generator-sitemap
- 用途: 生成 RSS方便别人订阅更新
- 安装:
pnpm install hexo-generator-feed --save - 配置: 在
_config.yml中修改配置
1 2 3 4
| feed: type: atom path: atom.xml limit: 20
|
发布功能 hexo-deployer-git
- 用途: 一键发布博客到GitHub Pages等平台
- 安装:
pnpm install hexo-deployer-git --save - 配置: 在
_config.yml中修改配置
1 2 3 4 5 6
|
deploy: - type: git repo: https://仓库地址 branch: master
|
- 效果: 执行
hexo clean && hexo generate -d && hexo deploy生成静态博客并发布
推送链接到搜索引擎 hexo-submit-urls-to-search-engine
- 用途: 利用这个插件配合hexo发布可以在发布新博客的时候同步把链接推送搜索引擎
- 安装:
pnpm install hexo-submit-urls-to-search-engine --save - 说明: 使用前需要先到对应平台申请 token,申请地址:bing、百度、谷歌
- 配置: 在
_config.yml中修改配置(插件详细配置说明)
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 26 27 28 29
| hexo_submit_urls_to_search_engine: submit_condition: count count: 10 period: 900 google: 1 bing: 1 baidu: 1 txt_path: submit_urls.txt baidu_host: https://blog.code52.cn baidu_token: bing_host: https://blog.code52.cn bing_enable_indexnow: false bing_token: google_host: https://blog.code52.cn google_key_file: file.json google_proxy: http://127.0.0.1:7897 replace: 0 find_what: https://blog.code52.cn replace_with: https://blog.code52.cn
deploy: - type: git repo: 地址 branch: master - type: cjh_bing_url_submitter - type: cjh_google_url_submitter - type: cjh_baidu_url_submitter
|