Search code examples
javascriptdisqussitefinity

Disqus for Sitefinity


I'm trying to figure out what's the best solution to the scenario below.

I'm showing my articles on the home page and also on the archive page. Home page Url structure is not the same as the archive page and I think that's where the confusion is coming from. When a visitor leaves a comment on an article on the home page, the comment does not show on the article in the archive page and vice versa.

This is the article Url structure on home page:

domain.com/portal/home/full-article/article-title/

and this is the Url structure on archive page:

domain.com/portal/archives/full-article/article-title/

and this the JavaScript code from Disqus:

<div id="disqus_thread"></div>
        <script>
            /*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 = '//short-name.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" rel="nofollow">comments powered by Disqus.</a></noscript>

I want the comments to sync and show on the home page and the archive page. As of now, the comments are showing differently depending on the page the visitor picked to leave a comment.

I read the documentation but I'm not sure if un-commenting this.page.url and this.page.identifier helps with this situation. If it does, what values should I use in Sitefinity?


Solution

  • The identifier sets the Disqus thread.

    https://help.disqus.com/customer/portal/articles/472095-how-do-i-load-the-same-thread-of-comments-on-multiple-pages-

    You need to make sure the identifier value is set to something that is unique, in your case the article.

    If the identifier is missing, it uses the url

    Read more here: https://help.disqus.com/customer/portal/articles/472098-javascript-configuration-variables