Comment Functionality

What do you recommend when users want to add comment functionality to their contentful site?

TL;DR.

Using 3rd party services for comment engines, such as Disqus or MUUT, is the best way to do it.

Why?

Contentful is optimised for “write once - deliver millions of times” kinds of content. Therefore having comments live within the system will defeat it’s optimisations and slow down your applications performance.

How?

In the case of Disqus, depending on your architecture there are a few different ways to implement it. For example, for Jekyll installations, there are integrated functionalities to directly embed Disqus. But if you’re using a solution you’ve built yourself, or a framework that doesn’t have a Disqus implementation, you can use the Universal Code Embed.

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

/**
*  RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
*  LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables*/
/*
var disqus_config = function () {
this.page.url = PAGE_URL;  // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = PAGE_IDENTIFIER; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
};
*/
(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
s.src = 'https://EXAMPLE.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>

Hope this helps,

Cheers

I agree with @david.litvak, having used both Disqus and MUUT.

Protip: consider using a “Tap to comment” button instead of loading Disqus/MUUT on initial page load, as they’re both taxing on your page load speeds.

2 Likes

@jason Yep. Good to know! Thanks for suggestion :+1: