不蒜子統(tǒng)計站點的總訪問量,即統(tǒng)計瀏覽了多少次;有多少人訪問嫉入,在footer顯示。
LeanCloud統(tǒng)計單篇博文的閱讀量璧尸,即統(tǒng)計單篇博文的閱讀量是多少劝贸。
不蒜子配置使用
下面教程針對NexT
主題設(shè)置。
找到站點的themes/next/layout/_partials
目錄下的footer.swig
文件逗宁。插入代碼如下。
{% if theme.copyright %}
<div class="powered-by">
{{ __('footer.powered', '<a class="theme-link" ) }}
</div>
<div class="theme-info">
{{ __('footer.theme') }} -
<a class="theme-link" >
NexT.{{ theme.scheme }}
</a>
</div>
# 此位置插入以下代碼
<div>
<script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>
本站總訪問量 <span id="busuanzi_value_site_pv"></span> 次   
本站訪客數(shù)<span id="busuanzi_value_site_uv"></span>人次
</div>
{% endif %}
LeanCloud配置使用
不蒜子也可以統(tǒng)計單篇博文的閱讀量梦湘,但是有兩個缺點:
- 在首頁不能查看博文的閱讀量瞎颗。
- 不能管理相關(guān)博文的閱讀量(我認為是缺點)件甥。
所以我使用LeanCloud。
新建Class
所以使用LeanCloud哼拔,網(wǎng)站可以使用Github綁定登錄引有,按提示完成登錄。登錄后倦逐,進入控制臺譬正,創(chuàng)建一個新應(yīng)用。點擊存儲
檬姥,按下圖標(biāo)記新建Class曾我,Class名稱必須為Counter。
image
添加ID和Key
按下圖標(biāo)記復(fù)制 App ID
和App Key
image
復(fù)制后健民,更改主題配置文件
的 leancloud_visitors:
抒巢。注意將enable
設(shè)為true
。
# Show number of visitors to each article.
# You can visit https://leancloud.cn get AppID and AppKey.
leancloud_visitors:
enable: true
app_id: #your App ID
app_key: #your App Key
設(shè)置安全域名
如下圖標(biāo)記設(shè)置安全域名:
image
總結(jié)
完成上面的部署后秉犹,運行如下命令同步博客:
$ hexo clean
$ hexo g
$ hexo d