# Hexo NJK 樣板添加訪客統計數 以 shoka 為例


# 在主題下添加 busuanzi 控制選項

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# Show PV/UV of the website/page with busuanzi.
# Get more information on http://ibruce.info/2015/04/04/busuanzi/
busuanzi:
# count values only if the other configs are false
enable: true
# custom uv span for the whole site
site_uv: true
site_uv_header: <i class="fa fa-user"></i>
site_uv_footer:
# custom pv span for the whole site
site_pv: true
site_pv_header: <i class="fa fa-eye"></i>
site_pv_footer:
# custom pv span for one page only
page_pv: true
page_pv_header: <i class="fa fa-file-o"></i>
page_pv_footer:

# 找到主題的 Footer.njk

在主題中的 layout 去尋找 footer

並添加以下內容

1
2
3
4
5
6
7
8
9
10
11
12
{%- if theme.busuanzi and theme.busuanzi.enable %}
<!-- 不蒜子统计 -->
<span id="busuanzi_container_site_pv">
本站總訪問量<span id="busuanzi_value_site_pv"></span>次
</span>
<span class="post-meta-divider">|</span>
<span id="busuanzi_container_site_uv" style='display:none'>
本站訪客數<span id="busuanzi_value_site_uv"></span>人
</span>
<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
{%- endif %}


# 新增貼文的統計數

1
2
3
4
5
6
{%- if theme.busuanzi and theme.busuanzi.enable and not index %}
<!-- 不蒜子统计 -->
<span id="busuanzi_container_page_pv" style='display:none' class="<%= class_name %>">
<i class="icon-smile icon"></i> 閱讀次數:<span id="busuanzi_value_page_pv"></span>次
</span>
{%- endif %}