Hugo 添加评论功能

第 1 步: 获得 Giscus 原始标签 在 Giscus 官方 配置好以后,获得如下的 <script>...</script> 标签 <script src="https://giscus.app/client.js" data-repo="[在此输入仓库]" data-repo-id="[在此输入仓库 ID]" data-category="[在此输入分类名]" data-category-id="[在此输入分类 ID]" data-mapping="pathname" data-strict="0" data-reactions-enabled="1" data-emit-metadata="0" data-input-position="bottom" data-theme="preferred_color_scheme" data-lang="zh-CN" crossorigin="anonymous" async> </script> 第 2 步:配置 themes 目录的文件 不同的主题可能不一样,需要灵活转变,这里用 PaperMod 主题举例,该主题并未配置评论的 html,那么应该怎么办呢 首先进入 themes/<theme_name>/layouts/partials/ 在 <script>...</script> 代码复制到 comments.html 中,然后在 extend_footer.html 的末尾添加如下代码 {{- partial "comments.html" . -}} 这行代码本质上是用了 go-templates 语法,具体可以参考Template · Go语言中文文档 做到这步就可以看到评论了,但是依然会有一些问题 在任何页面都会产生评论功能,比如主页,就不是很好看 只能对特定主题生效,切换主题仍然需要重新配置 第 3 步:依然配置 themes 目录文件 如果我们在刚刚的 extend_footer.html 中输入这样一段代码 {{ ....

April 3, 2024 · 1 min · 194 words · JackyLee

Hugo 工作流

Huge 发布工作流 第一步:生成文章模板 hugo new --kind <archetypes> <path/to/post>/index.md # 例如 hugo new --kind post path/to/post/index.md 第二步:修改 tags 和 categories tags: [] categories: [] 第三步:创作 写文章 第四步:提交

April 3, 2024 · 1 min · 26 words · JackyLee

Hugo 简易教程

配置文件 默认的配置文件 sample-config.yml | hugo-PaperMod Wiki 优雅地添加图片 Hugo 博客插入图片的方法 | Cassius’s Blog 添加 tag 和 category 参考如下文章 Hugo 框架中文文档 标签分类 - Andbible taxonomies: category: categories tag: tags 参考 LoveIt Cassius’s Blog

April 3, 2024 · 1 min · 31 words · JackyLee