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:
- set
blog
as default layout for your posts, - enable flag
comments
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
For further actions, you may consider blocking this person and/orreporting abuse