
Mahiro-Blog 新手教程(五):评论系统接入(Giscus / Waline)
从配置项到页面验证,手把手接入 Giscus 或 Waline,并给出常见问题排查清单。
周二 4月 07 2026
629 字 · 4 分钟
评论系统是博客互动的核心功能之一。Mahiro-Blog 已经预留了 Giscus 和 Waline 两套接入能力,你只需要改配置即可启用。
1. 先看配置入口
核心配置在 mahiro.config.yaml:
comments.enable:是否启用评论comments.type:giscus/waline/nonecomments.giscus:Giscus 参数comments.waline:Waline 参数
页面渲染层会根据这个 type 自动选择组件。
2. 接入 Giscus(最省心)
适合:你已使用 GitHub,并希望低运维。
配置示例:
comments:
enable: true
type: giscus
giscus:
repo: yourname/yourrepo
repoId: R_kgDOxxxxx
category: General
categoryId: DIC_kwDOxxxxx
mapping: pathname
lang: zh-CN
inputPosition: top
reactionsEnabled: '1'
emitMetadata: '0'
loading: lazy你需要去 giscus.app 生成上述参数(尤其是 repoId 与 categoryId)。
3. 接入 Waline(更自由)
适合:你有自部署后端需求,希望评论能力更可控。
配置示例:
comments:
enable: true
type: waline
waline:
serverURL: https://your-waline-server
lang: zh-CN
emoji:
- https://unpkg.com/@waline/emojis@1.1.0/weibo
meta:
- nick
- mail
- link
requiredMeta: []
reaction: false
pageview: false建议先跑最小配置,确认能加载后再加高级选项。
4. 切换评论系统的正确姿势
只改一处:comments.type
- 从
giscus切到waline - 或从
waline切回giscus
其余配置保留,不影响未来回切。
5. 常见问题排查
5.1 页面不显示评论区
按顺序查:
comments.enable是否为truecomments.type是否拼写正确- 对应平台参数是否完整
5.2 Giscus 显示但无法发言
通常是仓库 Discussions 权限或分类配置错误,重点检查:
- 仓库是否开启 Discussions
repoId/categoryId是否匹配
5.3 Waline 接口报错
优先检查:
serverURL是否可访问- 后端是否正常运行
- 跨域/证书配置是否正确
6. 新手建议
- 没有强烈自部署需求:优先 Giscus
- 有评论数据自治需求:再考虑 Waline
先把评论功能跑通,再做皮肤和交互微调。
系列导航
新手专栏目录入口
发现错误或想要改进这篇文章? 在 GitHub 上编辑此页
Build #299 2026/4/7 12:20:30
5dfcd91 · 04/07 12:20
Comments