Dan Stutzman

Fixing a Disqus "identifier conflict"

Published 2014-01-05

Are several of your web pages all showing the same Disqus comments? Even though you're correctly setting the disqus_identifier and disqus_url variables?

Are you pondering over the identifier conflict help page or the mysterious "Disqus Discussions Editor" trying to figure out what to do?

Here's what seemed to fix it for me:

  1. I set the disqus_url variable too (previously I was only setting disqus_identifier).
  2. I added a character to the end of all my disqus_identifier assignments. Surprisingly, this did not make all the comments disappear; just the bad duplicate ones!
  3. Not sure if this was necessary, but I disabled the Disqus plugin when the hostname is localhost:8888.

Here's the code I used, in Ruby HAML syntax.

          - path = url_for(@page)
          - path = url_for(@last_post) if path == '/'
          - path = path.gsub('/blog', '').gsub(/\.html$/, '')
            = "var disqus_identifier = '#{path}1'; // add 1 to fix Disqus bug"
            = "var disqus_shortname = 'danielstutzman';"
            = "var disqus_url = 'http://www.danielstutzman.com#{path}';"
            if (document.location.host !== 'localhost:8888') {
            /* * * DON'T EDIT BELOW THIS LINE * * */
            (function() {
            var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
            dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
            (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);