Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Waldemar Panas
Waldemar Panas

Posted on • Originally published atwpanas.github.io on

     

How to add Disqus to your GitHub Pages

Add a partial with Disqus

Create a file_includes/disqus.html with following content. Then you need to replaceYOUR_DISQUS_NAME with shortname that is identifying your website onDisqus.

{% if page.comments %}<divid="disqus_thread"></div><script>vardisqus_shortname=YOUR_DISQUS_NAME;vardisqus_config=function(){this.page.url="{{page.url | absolute_url }}";this.page.identifier="{{page.id}}";};(function(){vard=document,s=d.createElement('script');s.src='https://'+disqus_shortname+'.disqus.com/embed.js';s.setAttribute('data-timestamp',+newDate());(d.head||d.body).appendChild(s);})();</script><noscript>Please enable JavaScript to view the<ahref="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>{% endif %}

Create a layout with comments

In folder_layouts create a new HTML fileblog.html. This layout will be extending default post layout with previously created partial.

---layout: 'post'---{{ content }}{% include disqus.html %}

Configure the new layout for all your posts

Now all you need to do to enable Disqus in your post is:

  • setblog as default layout for your posts,
  • enable flagcomments by default.

To do so append file_config.yml with that configuration.

defaults:-scope:path:""type:"posts"values:layout:"blog"comments:true

How to disable comments in selected post

Changecomments flag tofalse at the begging of post file.

---title: "My post without comments"comments: false---

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

  • Location
    Poland
  • Work
    Software Engineer at Allegro
  • Joined

More fromWaldemar Panas

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp