Adding comments capability to your Jekyll blog with Disqus

Posted by Dan Siwiec on March 16, 2015 jekyll blog disqus

Adding comments to your Jekyll blog is very easy with Disqus support. There are 3 simple steps:

Register your page on Disqus

Go to Disqus and follow the registration steps

Embed in your site

Copy the universal code and paste it in _layouts/posts.html where you want the comments section to show

Fill out the two variables in the script url and identifier

url - your canonical website URL:

 this.page.url = '{{ site.url }}{{ page.url }}' ; 

identifier - use the title of the page:

this.page.identifier = 'Adding comments capability to your Jekyll blog with Disqus';

Optional Making comments optional

  • Surround the Disqus script with
{% if page.comments %}

and

{% endif %}
  • Create a default property in _config.yml:
defaults:
  -
    scope:
      path: ""
      type: "posts"
    values:
      comments: true

This will enable comments on your posts by default. If you wish to disable comments for a particular post just add comments: false in the Front Matter

Done.