如何使用hugo搭建個人部落格(四):添加評論系統disqus

來源:互聯網
上載者:User
這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。

按照官方說法,只需要在config.toml檔案中加上disqus的shortname即可讓部落格擁有disqus評論系統的功能。但折騰許久未能成功,現提供另一種添加disqus的方式。

1.註冊disqus
官網註冊帳號 https://disqus.com/
使用方式可以參考 http://alfred-sun.github.io/blog/2014/12/05/github-pages/

**2.使用disqus**這裡使用universal code的方式,將產生的code放到新檔案comments.html中:

<div id="disqus_thread"></div><script>/*** RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.* LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables*//*var disqus_config = function () {this.page.url = PAGE_URL; // Replace PAGE_URL with your page's canonical URL variablethis.page.identifier = PAGE_IDENTIFIER; // Replace PAGE_IDENTIFIER with your page's unique identifier variable};*/(function() { // DON'T EDIT BELOW THIS LINEvar d = document, s = d.createElement('script');s.src = '//wwwlearnbetterclub.disqus.com/embed.js';s.setAttribute('data-timestamp', +new Date());(d.head || d.body).appendChild(s);})();</script><noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript>

**註:**s.src請修改為自己的帳號資訊
comments.html與header.html在同一個目錄。

顯示效果:


3.博文中的comments可以關閉disqus功能
可以對某篇博文單獨關閉disqus功能。如test.md

+++Categories = ["test"]Description = "test"Tags = ["test"]menu = "main"title = "test hugo"comments = false      #這裡的comments取值為false,disqus則不可見date = 2014-08-09T05:04:40Z+++hello hugo! I am test.md

comments取值為false的顯示效果為:

註:如果使用多說評論,請參考 http://tonybai.com/2015/09/23/intro-of-gohugo/

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.