Hugo PaperMod主题添加utterances评论

What is ‘utterances’

https://utteranc.es/

utterances 是一款基于 GitHub issues 的开源评论插件. 主打免费开源~

安装Utterances

申请Github App

  1. 打开 Utterances 进行安装

  2. 选择要连接的库

    1. 确保选择的库是公开(public)的,否则你的读者将无法查看问题/评论。
    2. 确保在对应库安装应用程序,否则用户将无法发表评论。
    3. 如果你的库是fork的一个分支,在设置页面中并确保issues功能是打开的。

修改站点配置文件

  1. 在根目录layouts\partials下创建comments.html文件并编辑(注意不是主题文件夹中的layouts)

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    
    {{- /* Comments area start */ -}}
    {{- /* to add comments read => https://gohugo.io/content-management/comments/ */ -}}
    <script src="https://utteranc.es/client.js"
        repo="安装app的个人库名"
        issue-term="title"
        label="Comment"
        theme="github-light"
        crossorigin="anonymous"
        async>
    </script>
    {{- /* Comments area end */ -}}
    

    其中 repo格式类似于:0x4b404ec/0x4b404ec.github.io

  2. 在根目录修改config.yaml文件, 修改site参数params.commentstrue(同时也要确保page的配置文件中comments也为true

    1
    2
    
    params:
    	comments: true