{{craftSnippets}}
Home Articles Plugins Starter theme About
  • Home
  • Articles
  • How to add Disqus comments to Craft CMS website
Posted on May 17, 2019 by Piotr Pogorzelski

How to add Disqus comments to Craft CMS website

In this article, you will learn how to set up Disqus comments on your Craft CMS website - without the use of any plugins.

First, you need to set up Disqus account and obtain your unique shortname. After that, just include this Twig component in a place where comments should appear. Don't forget to set shortname variable!

{% set shortname = 'YOUR_WEBSITE_SHORTNAME' %}
{% if entry is defined %}
    <div id="disqus_thread"></div>
    <script>
    var disqus_config = function () {
    this.page.url = '{{entry.url}}';  
    this.page.identifier = '{{entry.id}}'; 
    this.page.title = '{{entry.title}}';
    };
    (function() { // DON'T EDIT BELOW THIS LINE
    var d = document, s = d.createElement('script');
    s.src = 'https://{{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.'|t}}</noscript>
{% endif %}

Comments posted using this Disqus form will be assigned to the current entry.

This code is based on Disqus universal embed code. I stripped away unnecessary comments, added Twig variables representing current entry, added title setting (otherwise Disqus thread would be called "Untitled") and enabled static translation for <noscript> message.

Disqus plugin #

If you want to use Disqus Single Sign-On functionality, use nystudio107 Disqus plugin.

SSO allows you to use Craft built-in user accounts for commenting - commenters don't need to sign in using Disqus authentification. Besides that, Disqus plugin also allows you to display comments counter in various parts of the page.

If your website does not use user accounts for visitors, i suggest using plugin-less solution.

Comments plugin #

What if Disqus is not your thing? If you need comments seamlessly integrated with your website, Comments plugin might be a solution for you.

This plugin does not rely on external service like Disqus. It stores comments in database and allows you to to manage all comment related matters from Craft control panel.

Comments plugin is surely more advanced solution than Disqus integrations, but it comes with a price - it costs 49$. There is also a fact to consider - due to being more complicated, Comments plugin can take bit longer to set up, configure and deploy.


TAGS:
#Craft CMS 3 #Template components
Quick links for this article:
Disqus Twig component on github gists
Let the expert handle
your Craft CMS project.
70 Basic icons by Xicons.co
[email protected]
Copyright © 2026 Piotr Pogorzelski
[email protected]      LinkedIn profile      Github profile