1、首先你要有个百度账号,然后登录百度统计https://tongji.baidu.com新增网站,添加完毕后到代码获取拿到统计脚本,如下:
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?e1359e896ec5e?????0336cdd19f894";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
这里我们需要的是e1359e896ec5e???0336cdd19f894这一串key
2、拿到key后,去到Hexo根目录下的themes\next\,打开**_config.yml**文件,找到baidu_analytics,在后面加上key值,如下:
# Baidu Analytics
baidu_analytics: e1359e896ec5e?????0336cdd19f894
3、然后重新编译,打包上传就可以了
$hexo g
$hexo d
4、测试,去到百度统计,找到代码安装检查,就可以测试是否添加上去了,检查成功有如下界面:
https://sweetolive.github.io/