本博客hexo用到的插件总结
hexo + next + github pages 搭建的个人静态博客,网上有很多搭建的过程,这里就不再叙述。重点记录一下博客中用到的插件
Hexo 一键部署插件
地址
安装配置
安装插件:
npm install hexo-deployer-git --save
然后修改站点配置文件 _config.yml中的配置:
deploy:
- type: git
repo: git@github.com:Diesel-Chen/diesel-chen.github.io.git
branch: master
Hexo文章永久链接插件
地址
安装配置
安装插件:
npm install hexo-abbrlink --save
然后我们可以在站点配置文件_config.yml中修改为:
url: https://dieselchen.work
permalink: archives/:abbrlink.html
abbrlink:
alg: crc32
rep: hex
permalink_defaults:
Hexo字数和阅读时间统计插件
地址
安装配置
安装插件:
npm install hexo-symbols-count-time --save
在站点配置文件_config.yml中添加一下代码:
symbols_count_time:
symbols: true
time: true
total_symbols: true
total_time: true
然后由于此插件集成在Next中,然后修改主题配置文件_config.yml:
symbols_count_time:
separated_meta: true
item_text_post: true
item_text_total: false
awl: 4
wpm: 275
Hexo博客站点sitemap的使用
启用sitemap功能
为了让博文被google或百度检索,需要使用hexo的sitemap功能。修改themes/next/_config.yml:
menu:
home: / || home
#about: /about/ || user
tags: /tags/ || tags
categories: /categories/ || th
archives: /archives/ || archive
#schedule: /schedule/ || calendar
sitemap: /sitemap.xml || sitemap
#commonweal: /404/ || heartbeat
安装插件
切换到hexo根目录下,安装搜索引擎插件,插件根据自己的需要安装其中一个或者都安装:
npm install hexo-generator-sitemap --save
npm install hexo-generator-baidu-sitemap --save
如何此时你跟我一样使用的是next主题,直接执行如下命令即可访问站点地图:
hexo g
此时,在public的静态文件根目录中会多出一个sitemap.xml文件,表示谷歌检索的sitemap安装成功。
谷歌检索
检测网站是否被检索
以GitHub Pages为例,新建的GitHub Pages是没有被谷歌检索的。在谷歌搜索栏中输入如下信息进行检索:
site: xxx.github.io
xxx为你的GitHub账号,如果没有被检索,不会显示hexo中的任何博文,如果有下面的步骤就可以省略了。
验证站点
需要谷歌账号,没有的可以申请一个。登录GoogleSearchConsole,点击立即使用,输入需要验证所有权的网站地址,例如本站地址
https://dieselchen.work
对于hexo博客网站,最好使用HTML标记 法验证网站所有权,我发现next主题有更好的配置方式,千万不要采用修改head.swig文件的方法,不然在升级NexT版本时会遇到很多不必要的麻烦。修改themes/next/_config.yml文件:
# Google Webmaster tools verification.
# See: https://www.google.com/webmasters
google_site_verification: xxxxxxxxxx
然后生成静态文件并发布:
hexo g
hexo d
回到谷歌搜索控制台继续进行验证,点击完成 。
添加sitemap.xml
打开谷歌控制台选择上一步添加的网站->索引 ->站点地图 ,在添加新的站点地图中填入”sitemap.xml”即可,添加成功会在已提交的站点地图 中显示,过一段时间在概述 中会显示被索引的情况。
百度检索
添加站点
登录百度资源管理平台,依次点击用户中心 ->站点管理 ->添加网站 (网站会随时更新,路径可能不同,只要找到添加网站的位置就可以)。
- 输入网址
https//dieselchen.work
//(注意协议头,gitpage在http基础上要加s)
- 站点属性
最多可以选择三项,建议相关的都选上,提高曝光度 - 验证网站
NexT主题选择HTML标签验证即可 ,复制标签中的content值,修改next配置文件_config.yml:
# Baidu Webmaster tools verification.
# See: https://ziyuan.baidu.com/site
baidu_site_verification: xxxxxxxxxx
# Enable baidu push so that the blog will push the url to baidu automatically which is very helpful for SEO.
baidu_push: true
百度资源页面先不要关闭,执行下面的步骤之后再点击完成验证 。
发布并验证
hexo根目录下执行如下命令:
hexo g
hexo d
回到百度资源网站,点击完成验证 。