I recently enabled the pretty-url feature in Jekyll, which removes the redundant
.html suffix in
URLs. You can enable it by adding
permalink: pretty in your
_config.yml. This of course
broke Disqus comments on all existing pages.
Hopefully, this can be easily fixed using the cool migration tools Disqus provides. The concept is to write a text file which maps the old URLs to the new ones. The file format should be the like the following snippet.
Disqus provides a CSV file which contains all your site’s URLs. To download this file, navigate
to your site’s admin panel and start the URL mapper tool under tools → migrate threads →
start URL mapper. Then download the CSV by clicking the
download CSV link.
First we need to get rid of the silly windows CRLF line endings from the CSV file. A little perl magic can help here.
Then, we need to format the file accordingly. The new URL is the old one without the
Again using perl, we can cook a simple script to automate the process.
I didn’t bother to allow passing the filename as a script argument, so I just ‘hardcoded’ the filenames in the script. Edit at will and don’t forget to run it from the proper path.
Finally, upload the new CSV file to the URL migration tool and you will have your old comments back.