选择统计工具

  1. 使用自己写的工具
  2. 使用不蒜子
  3. 使用 Vercount

修改文件

  1. 修改配置文件(增加开关)

    修改 hugo.yaml

    1
    2
    3
    4
    
       params:
         addons:
           vercount: # Vercount 网站计数器 https://github.com/EvanNotFound/vercount
             enable: true
    
  2. 修改页面

    修改 themes/PaperMod/layouts/partials/extend_footer.html 增加以下内容

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    
       {{- /* Footer custom content area start */ -}}
       {{- /*     Insert any custom code web-analytics, resources, etc. here */ -}}
       {{ if .Site.Params.addons.vercount.enable -}}
       <script defer src="https://events.vercount.one/js"></script>
       <footer class="footer">
         <span>
           总访问次数:<span id="vercount_value_site_pv">Loading</span> 次(<span id="vercount_value_site_uv">Loading</span> 人)
           本页面访问:<span id="vercount_value_page_pv">Loading</span>     </span>
       </footer>
    
       {{- end -}}
       {{- /* Footer custom content area end */ -}}
    

效果

Figure 1: 截图

Figure 1: 截图

查看统计

  1. 访问 https://www.vercount.one/dashboard ,然后登陆/注册(可使用 github 认证)

  2. Domain 菜单中添加你的域名,我的是 karlcw.top

    这一步还需要验证你是否佣有这个域名,忘记截图了;第一种是需要修改 DNS 相关的配置没有看懂,第二种是在网站中创建一个文件。

    我使用第二种,具体是在 hugo 的 public 中创建文件 ;

    1
    2
    3
    4
    5
    
       cd public
       mkdir .well-known
       cd .well-known
       touch vercount-verify-xxxxxxxxxxxxxxxxxxxx.txt
       echo 'xxxxxxxxxxxxxxxxxx' > vercount-verify-xxxxxxxxxxxxxxxxxxxx.txt