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.