Same Disqus Comments Showing up on Every Post?

I’ve been unable to fix the fact that every post is displaying the same comment thread on my site.

I have read this Disqus help post and still I can’t solve it.

I am using Hugo’s built-in disqus template. I am calling it with {{ template "_internal/disqus.html" . }}
My disqusShortname variable is set properly in config.toml

I then tried making a disqus partial as listed on the Hugo comments guide, and I set the identifier to be "{{ .Permalink}}id" so each post would have a unique identifier since each post has a different permalink.

No matter what I still see my comments appearing on every post. What is going on?

EDIT: Here’s a source, this version doesn’t include me setting the URL and identifier manually but you can see it in previous commits. Either way the default for the identifier should be unique based on the page URL. Also note that disqus is currently disabled in the config because I don’t wont people making broken comments.

Instead of {{ partial "disqus.html" . }}, just use {{ template "_internal/disqus.html" . }}. Everything should work alright. Have you checked your Disqus admin panel, there might be some useful information.

Also, the current disqus snippet is somewhat different that the one included in Hugo. That might cause problem. Can’t say for sure without further testing.

I tried that already, as noted in my original post.

My theme (Cactus Plus) actually came with a disqus partial built-in, so the theme’s partial was the first thing I tried.

When that didn’t work I used Hugo’s built-in disqus template.

And when that didn’t work I switched back to a partial, but I customized it to make sure it was sending a unique URL and identifier. Nothing has worked so far.

Try with a more up-to-date Disqus snippet in your partial: https://disqus.com/admin/universal

<div id="disqus_thread"></div>
<script>
    var disqus_config = function () {
        this.page.title = {{ .Title }};
        this.page.url = {{ .Permalink }};
        this.page.identifier = {{ .Permalink }};
    };
    (function() {
        var d = document, s = d.createElement('script');
        
        s.src = 'https://{{ .Site.DisqusShortname }}.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>

No luck. I updated the source and published the site with broken commenting. You can see how I commented on Day 13 but it appears on every post.

If I print the permalink below the Disqus section, I can see that it’s unique for each post. I can’t understand why Disqus won’t recognize the identifier as unique.

Edit: Also, I tried deleting my Disqus page and making a new one in case I messed up a setting somewhere

What happens if you change identifier to this?
this.page.identifier = {{ .Title }};

Just published it with that change, didn’t seem to affect anything.

I wish I knew how to see exactly what identifiers that script is generating.

You can see that in the html source from you browser.

Anyway, I think it’s not any bug related to Hugo. Most probably, Disqus is doing something wrong. You can check your disqus threads from here: https://disqus.com/admin/discussions

Identified the problem. Disqus is ignoring the last part of your URL (i.e. 12 or 13 or 14) because they are just numbers. Problem is that, the rest of the url is same for every post.

Try changing the urls of your posts to something like this: https://mattrossman.github.io/energize-andover-blog/post/day-14

That should solve your problem!

Ok, so that eventually worked! The only other thing was that I had to delete my disqus page for the site, then make it fresh again.

I used a terminal script to quickly rename all my post file names:

$ for FILENAME in *; do mv $FILENAME day-$FILENAME; done

Thank you for your help, that’s really bizarre that Disqus wouldn’t recognize the numbers in the URL. If anyone has an explaination for this I’d love to hear it.

The most probable reason for this behavior is - many other sites (using tradition CMS and others) has this type of url pattern: https://example.com/:section/:slug/:id. So, Disqus just throws away the last part if it contains only numbers.

Also, from the SEO point-of-view, your post’s url should represent it’s content. So, every post should have unique slug in its url (not just an unique numerical id).

Possibly related:
Improve the built-in Disqus template by @yihui at https://github.com/gohugoio/hugo/pull/3639