"We were unable to load Disqus." with jekyll's default minima theme
Asked Answered
S

4

6

When setting up my personal blog with jekyll, I found that I cannot get the comments section shown. It kept telling me:

We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.

Relevant code: (For the complete code, please visit my repo: https://github.com/sunqingyao/sunqingyao.github.io)

_config.yml

disqus:
  shortname: sled-dog

_layouts/post.html

{% if site.disqus.shortname %}
  {% include disqus_comments.html %}
{% endif %}

disqus_comments.html

{% if page.comments != false and jekyll.environment == "production" %}

  <div id="disqus_thread"></div>
  <script>
    var disqus_config = function () {
      this.page.url = '{{ page.url | absolute_url }}';
      this.page.identifier = '{{ page.url | absolute_url }}';
    };
    (function() {
      var d = document, s = d.createElement('script');
      s.src = 'https://{{ site.disqus.shortname }}.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>
{% endif %}

I've read through the troubleshooting guide several times and checked every possible situation, but the comments are still not appearing.

A few things to note:

  1. I'm using minima, jekyll's default theme, and following its document.
  2. I've registered a Disqus account and verified email address.
  3. My website shortname is sled-dog.
  4. github.io has been added to "Trusted Domains".
Suspicious answered 12/1, 2017 at 12:48 Comment(0)
C
9

There is an error in the this.page.identifier variable.

It should contain the page's unique identifier, but it is currently setting the page's url: this.page.identifier = '{{ page.url | absolute_url }}';

You should change it to:

this.page.identifier = {{ site.disqus.shortname }}';

再见

  • Update

Surround var disqus_config with comment tags: /* var disqus_config = ...*/.

Conciliar answered 12/1, 2017 at 13:18 Comment(8)
谢谢你!However, it's still not working: sunqingyao.github.io/miscellaneous/2017/01/12/… :( Can you see the comments section in your browser? I suspect there might be some problems with my network configuration. You know, we have GFW in China...Suspicious
Strange, I have the same code as yours (github.com/marcanuy/simpleit.rocks/blob/master/_includes/…), the only difference is the var disqus=config surrounded by comment tags: ` /* var disqus_config = ...*/`.Conciliar
After commenting out the var disqus_config part, everything works like magic! I can't tell the reason under the hood, but it just works...Suspicious
Please edit your answer, and I'll accept it immediately :)Suspicious
In my case, this.page.identifier modification was enough: csonuryilmaz.github.io Thanks @ConciliarWolframite
I think this should not work. the identifier should be unique, in this case it will be the same for all pages.Crofoot
this.page.identifier needs to have a unique id per disqus comments page. Setting it to shortname will cause overlapping comment sections if you have more than 1 pages where disqus comments are added on your page. I'm puzzled as to why this answer has so many likes.Colophon
How is this the right answer? The page.identifier should be unique to the each post, setting it to the shortname is probably collapsing all the comments in a single thread.Evanne
C
14

I'm surprised that the best answer is to disable discus.config.

If you have issues to enable disqus on your website with default jekyll theme, please check parameters.

_config.yml should include:

disqus: shortname: test-shortname

url: http://yourwebsite.com

JEKYLL_ENV should be set to "production"

export JEKYLL_ENV=production

That's all you need. Good luck.

Cartelize answered 28/10, 2017 at 20:18 Comment(1)
This is the correct answer, backed up by the official Minima README.Grasping
C
9

There is an error in the this.page.identifier variable.

It should contain the page's unique identifier, but it is currently setting the page's url: this.page.identifier = '{{ page.url | absolute_url }}';

You should change it to:

this.page.identifier = {{ site.disqus.shortname }}';

再见

  • Update

Surround var disqus_config with comment tags: /* var disqus_config = ...*/.

Conciliar answered 12/1, 2017 at 13:18 Comment(8)
谢谢你!However, it's still not working: sunqingyao.github.io/miscellaneous/2017/01/12/… :( Can you see the comments section in your browser? I suspect there might be some problems with my network configuration. You know, we have GFW in China...Suspicious
Strange, I have the same code as yours (github.com/marcanuy/simpleit.rocks/blob/master/_includes/…), the only difference is the var disqus=config surrounded by comment tags: ` /* var disqus_config = ...*/`.Conciliar
After commenting out the var disqus_config part, everything works like magic! I can't tell the reason under the hood, but it just works...Suspicious
Please edit your answer, and I'll accept it immediately :)Suspicious
In my case, this.page.identifier modification was enough: csonuryilmaz.github.io Thanks @ConciliarWolframite
I think this should not work. the identifier should be unique, in this case it will be the same for all pages.Crofoot
this.page.identifier needs to have a unique id per disqus comments page. Setting it to shortname will cause overlapping comment sections if you have more than 1 pages where disqus comments are added on your page. I'm puzzled as to why this answer has so many likes.Colophon
How is this the right answer? The page.identifier should be unique to the each post, setting it to the shortname is probably collapsing all the comments in a single thread.Evanne
C
0

Looking at original post by @nazlok, i had a similar issue after googling around, I found out the disqus short_name is not the same as the disqus account name. In fact it is site-specific.

From what I see in your _config.yml , your short_name: sled-dog could be your 'disqus account name'.

Confirm that you have the correct short_name for your site. See what-is-a-shortname on how to access the short_name.

Canaigre answered 4/1, 2020 at 14:48 Comment(0)
F
0

In my case, I was using a relative URL for this.page.url but it should be an absolute URL,

{{ page.url | absolute_url }}
Fascinate answered 28/2, 2021 at 20:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.