Hexo网站模板Giscus评论框配置方法

Lear 2025-05-02 10:00:00
Categories: > Tags:

Hexo网站模板Giscus评论框配置方法


giscus利用 GitHub Discussions 实现的评论系统,让访客借助 GitHub 在你的网站上留下评论。giscus 加载时,会使用 GitHub Discussions 搜索 API 根据选定的映射方式(如 URL、pathname、<title> 等)来查找与当前页面关联的 discussion。如果找不到匹配的 discussion,giscus bot 就会在第一次有人留下评论或回应时自动创建一个 discussion。
访客如果想要评论,必须按照 GitHub OAuth 流程授权 giscus app 代表他发布,或者可以直接在 GitHub Discussion 里评论。你可以在 GitHub 上管理评论。

如果要使用 giscus 评论系统,需要在 hexo 根目录中的 _config.yml,填写 giscus 配置
打开配置页面:https://giscus.app,在网页 配置 位置,填写自己用于保存留言的Github仓库名称,如我的留言板tagma067001068/giscus;并选择Discussion 分类,一般使用公告Announcements即可。
设置完毕后,下方的启用 giscus处会怎么生成以下配置项的具体内容,把配置内容复制到自己的_config.yml或_config.tree.yml配置文件的相应位置即可。
repo:
repo_id:
category_id:

默认是不使用,false
# optional, giscus comment
# get generated configurations from https://giscus.app/
# when enable is true, full out your repo、repo_id、category_id
giscus:
enable: false
repo:
repo_id:
category_id:
reactions_enabled: “1”
emit_metadata: “0”
input_position: “top”
theme: “preferred_color_scheme”
lang: “zh-CN”