hugo 博客增加评论系统
李二花 / 2020-01-15
外部系统
github 操作
创建一个 public 的 github 账号
utterances
使用 utterances app 对这个仓库进行授权
博客系统
增加配置
在 theme 下的 layouts/partials 下新增一个文件
# fileName: disqus.html
{{ if and (not (eq .Site.DisqusShortname "")) (and (not .Params.utterance.enable) (or (eq .Kind "404") (and (not .IsHome) .Content))) }}
<script src="https://utteranc.es/client.js"
repo="immotal/blog-comment"
issue-term="pathname"
theme="github-light"
crossorigin="anonymous"
async>
</script>
{{ end }}
找到 foot 相关的 html 文件(一般是 foot custom 中), 确认添加了如下标记(想要全局生效的话)
{{ if .Section }}
<nav class="post-nav">
<span class="nav-prev">{{ with .PrevInSection }}← <a href="{{ .RelPermalink }}">{{ .Title }}</a>{{ end }}</span>
<span class="nav-next">{{ with .NextInSection }}<a href="{{ .RelPermalink }}">{{ .Title }}</a> →{{ end }}</span>
</nav>
<script type="text/javascript">
document.addEventListener('keyup', function(e) {
if (e.target.nodeName.toUpperCase() != 'BODY') return;
var url = false;
if (e.which == 37) { // Left arrow
{{ if .PrevInSection }}
url = '{{ .PrevInSection.RelPermalink }}';
{{ end }}
} else if (e.which == 39) { // Right arrow
{{ if .NextInSection }}
url = '{{ .NextInSection.RelPermalink }}';
{{ end }}
}
if (url) window.location = url;
});
</script>
{{ end }}
{{ partial "google_adsense_footer.html" . }}
{{ partial "disqus.html" . }}
{{ partial "footer_prismjs.html" . }}
<script async src="/js/fix-toc.js"></script>
<script async src="/js/center-img.js"></script>
<script async src="/js/right-quote.js"></script>
<script async src="/js/fix-footnote.js"></script>
<script async src="/js/external-link.js"></script>
<script async src="/js/alt-title.js"></script>
<script src="/js/no-highlight.js"></script>
<script src="/js/math-code.js"></script>
{{ partial "footer_mathjax.html" . }}
{{ partial "footer_pseudocode.html" . }}
{{ if $.Page.Scratch.Get "mdc" }}
<script src="{{ $.Site.Params.materialComponentsWebCDN }}/material-components-web@{{ $.Site.Params.materialComponentsWebVersion }}/dist/material-components-web.min.js"></script>
<script>window.mdc.autoInit()</script>
{{ end }}
{{ if $.Page.Scratch.Get "douban-card" }}
<script src="/js/douban-card.js"></script>
{{ end }}
<script async src="/js/load-typekit.js"></script>
<script src="{{ $.Site.Params.lazysizesCDN }}/lazysizes/{{ $.Site.Params.lazysizesVersion }}/lazysizes.min.js"></script>
<script src="{{ $.Site.Params.vanillaBackToTopCDN }}/vanilla-back-to-top@{{ $.Site.Params.vanillaBackToTopVersion }}/dist/vanilla-back-to-top.min.js"></script>
<script>
addBackToTop({
diameter: 48
})
</script>
{{ if $.Page.Scratch.Get "figure-slider" }}
<script src="/js/figure-slider.js"></script>
{{ end }}
参考文档: - 评论系统