Hexo的hexo-theme-matery主题配置评论

0. 前言

之前写过一篇文章用Hexo搭建个人博客,介绍如何用Hexo搭建个人博客网站,使用了hexo-theme-matery主题,今天介绍一下这个主题下使用的评论插件。

1. 评论插件

matery主题集成了各种评论模块,例如 gitalkgitmentdisqusliverevalinewalineTwikooutteranc 等,今天要介绍的 utteranc 这种插件是集成在github种的评论插件,并且能够做到github邮箱通知。下面就来详细介绍一下utteranc如何配置

1.1 新建一个评论仓库

首先创建一个公开的评论仓库<自定义名称> !注意一定要公开,否则别人无法评论

1.2 安装utteranc

  • 进入utteranc,点击install
  • 选择刚刚创建的自定义评论仓库
  • repo输入自己刚刚新建的仓库
  • 其他按照自己的需要挑战,把最后生成的配置,copy 下来
ini 复制代码
<script src="https://utteranc.es/client.js"
        repo="ZBIGBEAR/sync_test"
        issue-term="pathname"
        theme="github-light"
        crossorigin="anonymous"
        async>
</script>

1.3 添加配置到matery主题

  • 修改matery主题的配置文件 themes/hexo-theme-matery/_config.yml ,开启utteranc功能
yaml 复制代码
# utteranc config, default disabled
# utteranc 评论模块的配置,默认为不激活
utteranc:
  enable: true
  • 修改博客文章 themes/hexo-theme-matery/layout/_partial/post-detail.ejs
scss 复制代码
<% if (theme.utteranc && theme.utteranc.enable) { %>
<%- partial('_partial/utteranc') %>
<% } %>

该处改动的目的是为了在所有博客文章中统一在底部加入一个评论模块,这个改动很关键、所放位置也很重要。

  • 新增一个文件 themes/hexo-theme-matery/layout/_partial/utteranc.ejs
ini 复制代码
<div class="card" data-aos="fade-up">
    <div id="utteranc-container" class="card-content">
        <script src="https://utteranc.es/client.js"
                repo="jijunhao/utterances"
                issue-term="pathname"
                theme="github-light"
                crossorigin="anonymous"
                async>
        </script>
    </div>
</div>

所有的留言都会出现在自定义评论仓库 issues 的,并且会每次给邮箱发消息。

  • 如果博客中还有单独的一个留言板模块,需要改 themes/hexo-theme-matery/layout/contact.ejs
scss 复制代码
<% if (theme.utteranc && theme.utteranc.enable) { %>
    <%- partial('_partial/utteranc') %>
<% } %>

最后重启hexo,就能在网页拥有评论功能了。

2. 参考

1用Hexo搭建个人博客

2Hexo-Matery主题评论插件

相关推荐
IT_陈寒17 小时前
SpringBoot自动配置这个坑,我踩进去又爬出来了
前端·人工智能·后端
copyer_xyf17 小时前
Agent 流程编排
后端·python·agent
copyer_xyf18 小时前
Agent RAG
后端·python·agent
copyer_xyf18 小时前
【RAG】向量数据库:milvus
后端·python·agent
铁皮饭盒18 小时前
Bun 哪比 Node.js 快?
javascript·后端
copyer_xyf18 小时前
Agent 记忆管理
后端·python·agent
葫芦和十三1 天前
图解 MongoDB 02|BSON:你以为存的是 JSON,其实是带类型的二进制
后端·mongodb·agent
葫芦和十三1 天前
图解 MongoDB 01|文档数据库
后端·mongodb·agent
陈随易1 天前
VSCode的Copilot扩展支持接入DeepSeek,Kimi了!
前端·后端·程序员
我不是外星人1 天前
有了 Harness Engineering ,真的还需要研发工程师吗?
前端·后端·ai编程