Sponsored by:

Disqus and the disappearing comments (which still exist)

Update (just a couple of hours later): We're fixed! By all means, read the background it you're having similar problems or jump to the bottom for the solution.

I'm writing this post because I've pretty much exhausted all other avenues. I'm out of ideas. I'm stumped. I'm also missing a truckload of Disqus comments that should be appearing on many of the blog posts I've just migrated. Let me explain what I've done and what I'm now seeing and hopefully between me trying to articulate this clearly and people reading this post, we'll work out how to get it fixed.

Some background first: earlier this week I wrote about my shiny new blog which I migrated over on Sunday my time, about five and a half days ago now. There were two important changes here as it relates to Disqus:

  • The scheme changed from HTTP to HTTPS
  • The paths of the posts changed too

Fortunately, Disqus has you covered for such changes (at least they should have you covered), and they outline migration tools including a domain migration (only any good when the paths don't change), a URL map of old URL then new URL and a redirect crawler which follows all your 301s. I elected to go with the URL map because it seemed like the most expeditious way forward. Here's an example of what's in the map:


This is the source URL and the target URL, the former which now also redirects to the latter. That present URL at https://www.troyhunt.com/lenovo-p50-and-my-dislike-of-high-dpi/ only has 3 comments showing on it as of today, but I'll come back to that. The entire map of 434 posts can be seen here.

As well as migrating the comments with the URL map, I also configured the Disqus div and script as follows:

<div id="disqus_thread"></div>
var disqus_config = function () {
this.page.url = 'https://www.troyhunt.com/lenovo-p50-and-my-dislike-of-high-dpi/';
this.page.identifier = 'ghost-1785';

(function() {
var d = document, s = d.createElement('script');

s.src = '//troyhunt.disqus.com/embed.js';

s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);

Now in theory, this should be it. Job done. The URL map might take up to 24 hours to run and that's cool, but something is still amiss. I want to start outlining the issues and ask for feedback but before I do that, please don't suggest I do [insert whatever] with the Disqus embed tags unless I've clearly screwed up what you see above. I say that merely because many of the suggestions via Twitter have pointed me to references on the tag setup and I don't believe that's where the problem is so unless you can see that I've clearly messed them up, let's instead focus on the next bit.

Going back to this post on the P50, here's the comments I'm presently seeing:

3 comments on the P50 post from the last 4 days

However, when I browse over to the Disqus portal, I can see comments like this which are clearly not showing up on the page:

A comment on the P50 in the Disqus portal which isn't appearing  on the post

Note the cursor over the post title and the URL in the status bar. That URL is https://www.troyhunt.com/lenovo-p50-and-my-dislike-of-high-dpi/#comment-2625929224 and if you click it, it will indeed open the P50 post yet when it opens, you won't see the comment on the page. To ensure I wasn't going insane, I even diff'd it against the URL of the post by browsing directly there from the homepage. The URL is good and there's no redirects or other funkiness going on. Why does this comment not appear on the blog post?!

Conversely, there are comments with the wrong URL that do show on the page. For example, the one comment of mine that's visible on the P50 page shows this URL in Disqus:

P50 comment linking to the troyhunt.ghost.io host name

Now again, this comment is presently showing up just fine on the P50 page yet in this image you can clearly see it links through to the troyhunt.ghost.io host name. This was the temporary path I used whilst building the blog before updating the DNS and pointing troyhunt.com to it. As part of my testing, I'd viewed this post on the troyhunt.ghost.io domain before making the site live which made me curios...

I viewed the Sony passwords post before rolling over DNS and I can only see one comment on it which was made since rollover.

I also viewed this TeamCity post before rollover and it has no comments.

But I didn't view this TeamCity post before rollover and it has comments just fine.

Somehow, any of the posts I viewed on the troyhunt.ghost.io domain now no longer have comments associated to them. The comments are still there in the Disqus portal so I have no reason to believe that I've actually lost them, but nobody can see them. For all intents and purposes, these posts presently have no comment history.

This is enormously frustrating. I've got posts such as the one on the massive Philippines election committee data breach which are making national news and getting many thousands of visits a day and there's an entire dialogue about the incident missing. I've tried re-uploading the URL map and I've tried the redirect crawler but I just can't get everything synced up. I've also tried Disqus support and whilst friendly, it hasn't led to a solution.

If you have a Disqus contact for me who might be able to get some results, please ping me.

If you're from Disqus, please let me know how to get this fixed.

I've been very happy with Disqus for many years and I love what the service does, I hope someone out there can help me piece things back together. Please do leave a comment if you've any ideas on how to fix this, I think I'll be able to read it...

We're fixed!

A big thanks to this thread with John Nobile below who suggested trying other URL maps. I eventually narrowed it down to this one, thus solving the problem:


Disqus was somehow re-keying the posts to Ghost's temporary domain, inevitably when I previewed the posts before rolling over DNS. I've noticed similar oddities when previewing a post in Ghost and then later changing the title before publishing it; Disqus (for some reason) picks up on that first URL it sees - even when there are no comments - and keeps a hold of it for perpetuity. There's probably some more insights to be had re that behaviour and I'm not sure why Disqus themselves couldn't identify this issue when I logged the support ticket, but right now I'm just glad to have my posts back.

For those who have similar problems in future, here's the revised map I uploaded. I did it for every single URL and for both HTTP and HTTPS schemes as I suspect I loaded some of them over the secure protocol so I wanted to cover my bases. I had every old and new URL mapped in a database so it was an easy query to write and it's done the trick!