Adding a comments section to your Jekyll blog can enhance reader engagement and foster a community around your content. One popular option is Disqus, a third-party commenting platform that is easy to integrate and manage. In this article, we will guide you through the steps to add Disqus comments to your Jekyll site.

Why Use Disqus on Your Jekyll Blog?

Disqus offers several benefits for bloggers:

  • Easy to set up and customize
  • Supports threaded discussions and moderation tools
  • Provides spam filtering and security features
  • Offers social media integration

Steps to Integrate Disqus Comments

1. Sign Up for Disqus

Visit the Disqus website and create a free account. After signing up, register your website by providing its name and URL. Disqus will generate a unique "Shortname" which you will need later.

2. Obtain Your Disqus Shortname

Once your site is registered, navigate to your Disqus admin panel. Find your site's shortname — a string of characters that identifies your site in Disqus. Keep this handy as you'll need it to embed the comments.

3. Add Disqus Code to Your Jekyll Site

Edit your Jekyll site's layout file, typically located at _layouts/post.html or similar. Insert the following code where you want the comments to appear, usually at the end of your post content:

Replace YOUR_DISQUS_SHORTNAME with your actual Disqus shortname.

<div id="disqus_thread"></div>

<script>

var disqus_config = function () {

this.page.url = '{{ page.url | absolute_url }}'; // Replace with your page's canonical URL variable

this.page.identifier = '{{ page.id }}'; // Unique identifier for each page

};

(function() {

var d = document, s = d.createElement('script');

s.src = 'https://YOUR_DISQUS_SHORTNAME.disqus.com/embed.js';

s.setAttribute('data-timestamp', +new Date());

(d.head || d.body).appendChild(s);

)();

</script>

<noscript>Please enable JavaScript to view the comments.</noscript>

Final Tips

Test your comments section after deploying the changes. Clear your cache if necessary. Remember to keep your Disqus shortname private and secure. With these steps, your Jekyll blog will be ready to host lively discussions with your readers.