在個(gè)人博客里添加評論系統(tǒng)--Gitalk

0 前言


前提是 搭建了博客,使用的主題是 jekyll-theme-H2O 這個(gè)主題。其余的可以借鑒,但不一定完全適用。

Gitalk 是一個(gè)評論系統(tǒng),在個(gè)人博客里添加了之后就可以很簡便的進(jìn)行評論和回復(fù)了。

1 注冊 GitHub Application


首先要注冊一下 GitHub Application,

https://github.com/settings/applications/new


注冊完就會有 Client ID 和 Client Secret

2 配置 _config.yml

在 comments 那添加

  gitalk: true
  gitalk_clientID: 'Client ID'
  gitalk_Secret: 'Client Secret'
  gitalk_repo: '用戶名.github.io'
  gitalk_owner: '用戶名'
  gitalk_admin: '用戶名'
  distractionFreeMode: true

是在 comments 下面那添加,不要搞錯(cuò)地方。


3 配置 post.html


文件的位置在 _layouts\post.html

3.0 在 <html> 這個(gè)標(biāo)簽下添加

<html> 這個(gè)標(biāo)簽下加上這兩行

<link rel="stylesheet" >
<script src="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js"></script>

就像這樣


3.1 在 {% include footer.html %} 里添加

<script src="https://cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js"></script>

如圖所示,位置不要搞錯(cuò)


3.2 在 {% if site.comments.disqus %} 后面添加

  {% if site.comments.gitalk %}
    <script>
        var gitalk = new Gitalk({
              clientID: '{{ site.comments.gitalk_clientID }}',
              clientSecret: '{{ site.comments.gitalk_Secret }}',
              repo: '{{ site.comments.gitalk_repo }}',
              owner: '{{ site.comments.gitalk_owner }}',
              admin: '{{ site.comments.gitalk_admin }}',
              id: location.pathname,      // Ensure uniqueness and length less than 50{{ page.title }}
              distractionFreeMode: '{{ site.comments.distractionFreeMode }}'  // Facebook-like distraction free mode
            })

            gitalk.render('disqus_thread')
    </script>
  {% endif %}

如圖所示


關(guān)于 post.html 這部分的修改可以看一下我的修改

保存修改,再提交。

4 開 issues


進(jìn)入博客,點(diǎn)擊設(shè)置



進(jìn)去后勾選一下 issues 就搞定了。


再去看一下你博客里面的文章,如果說出現(xiàn)了評論框,那就是成功了。


5 相關(guān)說明


參考了這篇文章才實(shí)現(xiàn)的:https://tea9.github.io/2018/06/24/gitali_config.html

文章作者寫的說明:http://note.youdao.com/publicshare/?id=6ea132ba501b49b2928125a694cc9ad9#/

使用的主題是:jekyll-theme-H2O

感謝兩位作者~~

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容