I noticed the other day that Disqus comments that were appearing on my site stopped showing up. Articles that had had 2 or 3 comments had started saying “no comments”.
Minor URL changes
After looking into it for a while, and googling a little bit, I realised that the reason was because I had made a slight change to the way my URLs are structured. For example:
https://robinwinslow.co.uk/2013/02/18/optimal-font-size.html -> https://robinwinslow.co.uk/2013/02/18/optimal-font-size/
I had very carefully made sure all the old URLs redirected properly to the new ones.
Disqus didn’t care that I’d taken all this care to create redirects. All it knew was that people had commented on an article at
../optimal-font-size.html and now they were asking to see comments at
../optimal-font-size/ (with a
/ in place of
.html), which isn’t the same thing at all, apparently.
Incidentally I think that this was a bit shit of Disqus - they should use 301 Permanent redirects to link URLs automatically to avoid this issue.
Disqus, to their credit, created a tool called “URL map”.
You can find the tool inside your Disqus admin area under Discussions -> Tools and use it to replace old incorrect URLs with the new ones.
When you go to your Disqus admin area (filtered by site, if you like), you can click “Discussions” and then “Tools” and then “Start URL mapper”.
Download existing URLs in CSV format
Now you can download the CSV of your existing URLs by clicking “you can download a CSV here”. This is definitely a good idea.
Open it up in your favourite text editor. It will look just like a list of URLs:
https://robinwinslow.co.uk/2013/05/31/installing-symfony-2-by-creating-a-github-fork.html https://robinwinslow.co.uk/2013/05/30/why-i-love-the-internet.html https://robin-blog.herokuapp.com/2013/05/29/ease-magento-development-with-bootstrapped-scripts.html ...
You want to edit it to add in replacement URLs, so it looks something like this:
https://robinwinslow.co.uk/2013/05/31/installing-symfony-2-by-creating-a-github-fork.html, https://robinwinslow.co.uk/2013/05/31/installing-symfony-2-by-creating-a-github-fork/ https://robinwinslow.co.uk/2013/05/30/why-i-love-the-internet.html, https://robinwinslow.co.uk/2013/05/30/why-i-love-the-internet/ https://robin-blog.herokuapp.com/2013/05/29/ease-magento-development-with-bootstrapped-scripts.html, https://robinwinslow.co.uk/2013/05/29/ease-magento-development-with-bootstrapped-scripts/ ...
Make it easier using regex in sublime
I edited it using sublime text - a fantastic editor, which support regular expressions. I used the following find and replace statement to transform the file into what I wanted it to be:
^(http://[^/]+)([^ .\n]+[^/.\n])/?(.html)?[^\n]*$ \1\2\3, https://robinwinslow.co.uk\2/
Which made it so much easier. If your requirements are similar to mine you can probably manage to copy this and tweak it slightly yourself. If they’re different, you’ll have to learn regex to use this solution if you don’t already know it.
Upload the file
Now I uploaded the file back to Disqus through the URL map tool, waited a few minutes, and voila! My old comments showed up under my new URLs!
As the tool will tell you, the only way to check this is to check if the missing comments start showing up again.