Hugo 添加評論功能

Hugo 添加評論功能

前言


Utterances 是一種基於 GitHub Issues 的評論系統。它允許在靜態網站中嵌入一個評論框,並將評論存儲在與自己的 GitHub 存儲庫相關聯的 Issues 中。

安裝 Utterances 及配置


步驟 1:到安裝頁面後點選 Install

image

步驟 2:選擇要安裝 Utterances 的 GitHub Repository

image

步驟 3:添加配置至程式碼中

可由官網進行配置

設置 repo 名稱

image

選擇訪客留言 issue 名稱

image

選擇主題

image

可複製產出的代碼貼在自己的 repo

這邊我是放在themes/layouts/partials資料夾建立一個comments.html,把生成的代碼複製過去。

<script
  src="https://utteranc.es/client.js"
  repo="ChrisLinOvO/ChrisLinOvO.github.io"
  issue-term="pathname"
  theme="github-light"
  crossorigin="anonymous"
  async
></script>

若每篇文章最底下要加評論,只需要在themes/layouts/_default/single.html裡加上

{{ partial "comments.html" . }}

結語


Utterances 是一個方便的評論系統,可用於 Hugo 靜態網站,它與 GitHub 整合,並通過 Issues 存儲評論,使評論管理變得簡單而有效。添加 Utterances 評論系統可以提升您的網站的互動性和參與度。