跳过正文
  1. 个人网站/

Hugo 博客如何添加 Giscus 评论系统

·403 字·1 分钟· loading · loading · ·
Fairchild
作者
Fairchild
土木逆子
14:30
目录
website - 这篇文章属于一个选集。
§ 2: 本文

本文将介绍如何为 Hugo - Blowfish 主题博客添加 Giscus 评论系统

在主题与插件生态、社区支持与文档等方面,Hugo 不及 Hexo。部分 Hugo 主题自带评论功能,比如 Clean White 目前支持 Giscus 、Disqus 和 Twikoo 三种评论系统。Blowfish 支持在文章底部添加评论,但没有提供局部模板

\blowfish\layouts\_default\single.html

0

第一步:为你的 Github 账户安装 giscus app
#

https://giscus.app/

第二步:启用仓库的 Github 讨论
#

第三步:获取配置信息
#

第四步:把 Giscus 引入 Blowfish
#

根据 Blowfish 主题手册
(1)需提供一个局部模板 layouts/partials/comments.html
(2)在 params.toml 配置文件中全局设置 [article] showComments = true,或在每篇文章的扉页参数中单独设置 showComments : true。扉页参数的默认值继承自全局参数,并支持单独修改。

直接使用 Clean White 主题comments.html

https://github.com/zhaohuabing/hugo-theme-cleanwhite/  

和其他第三方服务类似,在 params.toml 中添加 giscus 配置信息。

[giscus]
  data_repo="username/repository"
  data_repo_id="****************" 
  data_category="Announcements"
  data_category_id="****************"
  data_mapping="pathname"
  data_strict="0"
  data_reactions_enabled="1"
  data_emit_metadata="0"
  data_input_position="bottom"
  data_theme="transparent_dark"
  data_lang="en"
  crossorigin="anonymous"
提示
  • 注意代码格式,不以 , ; 结尾
  • comments.html 中使用下划线命名,在 params.toml 中要一致
  • comments.html 没有接受参数 data_theme,可以改一下

快去试试吧!