Hugo成功添加添加评论组件Utterances

我是用的这套hugo theme maupassant作者默认支持了两种评论系统,disqusUtterances

disqus安装失败,估计和其他blogger说的一样,被墙了。其实我已经注册成功,但配置以后一直不显示评论框。于是今晚试了一下Utterances,一击成功!复述一下配置过程:

  1. 在github新建一个仓库,可以命名为blog-comment
  2. Utterances选择安装在这个仓库里;
  3. 连接模式选择“pathname”;
  4. 如果你的theme像我一样支持Utterances,那就好办了,将配置文件粘贴进config.toml就搞定了,评论的Repo写成自己的仓库名,格式为 owner/repo ,比如我的就是“tihu/tihu-blog-comment”。
[params.utteranc]
    enable = true
    repo = "tihu/tihu-blog-comment"    # 存储评论的Repo,格式为 owner/repo
    issueTerm = "pathname"  #表示你选择以那种方式让github issue的评论和你的文章关联。
    theme = "github-dark" # 样式主题,有六种样式,基本够用了。
  1. 如果不直接支持,那就得折腾一下了,主要难点在于要修改theme对应页面片的样式,不过Utterances在安装页面已经帮你生成好代码片段了,复制粘贴即可;
<script src="https://utteranc.es/client.js"
        repo="tihu/tihu-blog-comment"
        issue-term="pathname"
        theme="dark-blue"
        crossorigin="anonymous"
        async>
</script>
Built with Hugo
Theme Stack designed by Jimmy