這是一個建立於
的文章,其中的資訊可能已經有所發展或是發生改變。
按照官方說法,只需要在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/