博客
关于我
hexo笔记十二:next主题统计网站与文章的浏览人数及次数
阅读量:782 次
发布时间:2019-03-21

本文共 1592 字,大约阅读时间需要 5 分钟。

注意的是,不同的浏览器显示效果不一样,这一点很坑。

1 修改主题配置文件中的自带的busuanzi_count(不知道怎么读)的统计功能

cd 博客目录vim theme/next/_config.yml# 将原来已有的那部分注释掉busuanzi_count:  enable: true  total_visitors: true  total_visitors_icon: user  total_views: true  total_views_icon: eye  post_views: true  post_views_icon: eye    # custom uv span for the whole site  #site_uv: true  #site_uv_header:   #site_uv_footer:  # custom pv span for the whole site  #site_pv: true  #site_pv_header:   #site_pv_footer:  # custom pv span for one page only

2 修改busuanzi_count的配置文件

cd 博客目录vim theme/next/_config.ymlcd themes/next/layout/_third-party/analytics/# 将原有的busuanzi-counter.swig备份一下mv busuanzi-counter.swig busuanzi-counter.swig.bak# 再建一个新的busuanzi-counter.swig文件vim busuanzi-counter.swig# 将下面的内容复制到新建的busuanzi-counter.swig文件中{   % if theme.busuanzi_count.enable %}
{ % if theme.busuanzi_count.total_visitors %}
已有人访问 { % endif %} { % if theme.busuanzi_count.total_visitors and theme.busuanzi_count.total_views %}
{ % endif %} { % if theme.busuanzi_count.total_views %}
总访问 { % endif %}
{ % endif %}

3 另外可以更改下底部的建站图标和时间

cd 博客目录vim theme/next/_config.yml# 更改相应的配置footer:  # Specify the date when the site was setup.  # If not defined, current year will be used.  since: 2019  # Icon between year and copyright info.  # icon: user  icon: snowflake-o #图标会显示为一个雪花的样式

4 重新生成

cd 博客目录hexo g

可以看到效果

在这里插入图片描述
总访问人数是由cookies决定,safari浏览器每次刷新,cookies都不一样,所以每次刷新访问人数都会增加。而Chrome和Firefox浏览器每次刷新cookies不会改变,只会增加总访问量,而访问人数不会变。(Chrome开启匿名模式,每次刷新后,cookies也会改变)

转载地址:http://bdtez.baihongyu.com/

你可能感兴趣的文章
MySQL 多表联合查询:UNION 和 JOIN 分析
查看>>
MySQL 大数据量快速插入方法和语句优化
查看>>
mysql 如何给SQL添加索引
查看>>
mysql 字段区分大小写
查看>>
mysql 字段合并问题(group_concat)
查看>>
mysql 字段类型类型
查看>>
MySQL 字符串截取函数,字段截取,字符串截取
查看>>
MySQL 存储引擎
查看>>
mysql 存储过程 注入_mysql 视图 事务 存储过程 SQL注入
查看>>
MySQL 存储过程参数:in、out、inout
查看>>
mysql 存储过程每隔一段时间执行一次
查看>>
mysql 存在update不存在insert
查看>>
Mysql 学习总结(86)—— Mysql 的 JSON 数据类型正确使用姿势
查看>>
Mysql 学习总结(87)—— Mysql 执行计划(Explain)再总结
查看>>
Mysql 学习总结(88)—— Mysql 官方为什么不推荐用雪花 id 和 uuid 做 MySQL 主键
查看>>
Mysql 学习总结(89)—— Mysql 库表容量统计
查看>>
mysql 实现主从复制/主从同步
查看>>
mysql 审核_审核MySQL数据库上的登录
查看>>
mysql 导入 sql 文件时 ERROR 1046 (3D000) no database selected 错误的解决
查看>>
mysql 导入导出大文件
查看>>