Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disqus 不能load的一种可能分析和解决方案 #876

Closed
forwardkth opened this issue May 8, 2016 · 9 comments
Closed

disqus 不能load的一种可能分析和解决方案 #876

forwardkth opened this issue May 8, 2016 · 9 comments

Comments

@forwardkth
Copy link

更新主题以后,disqus在新建的post上无法load,但是以前的post上load正常

网上的一个文章 http://webcache.googleusercontent.com/search?q=cache:UnY-n6LaBqgJ:www.xlgps.com/article/171989.html+&cd=6&hl=zh-CN&ct=clnk&gl=se
给了我启发。

于是我更改了主题 layout script
disqus.swig 中的disqus_url 为自己的域名,于是问题解决了。

我觉得这可能是个潜在的bug

//////////////////////////////////////////////////////////////////////////////
{% if not (theme.duoshuo and theme.duoshuo.shortname) and not theme.duoshuo_shortname %}

{% if theme.disqus_shortname %}

<script type="text/javascript">
  var disqus_shortname = '{{theme.disqus_shortname}}';
  var disqus_identifier = '{{ page.path }}';
  var disqus_title = '{{ page.title }}';
  var disqus_url = 'http://forwardkth.github.io';  #这里修改为自己的域名

  function run_disqus_script(disqus_script){
    var dsq = document.createElement('script');
    dsq.type = 'text/javascript';
    dsq.async = true;
    dsq.src = '//' + disqus_shortname + '.disqus.com/' + disqus_script;
    (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
  }

  run_disqus_script('count.js');
  {% if page.comments %}
    run_disqus_script('embed.js');
  {% endif %}
</script>

{% endif %}

{% endif %}

@iissnan
Copy link
Owner

iissnan commented May 9, 2016

你的站点配置文件里的 url 字段是填写什么?

@forwardkth
Copy link
Author

站点配置文件的url我是留空的,因为不确定应该填什么。升级主题以前那里也是留空的,但是disqus没有出现问题。所以现在这个情况比较不解 : )

@iissnan
Copy link
Owner

iissnan commented May 10, 2016

我会把 disqus_url 这个变量去掉,有 disqus_identifier 就可以。至于页面的链接,Disqus 会自动取 window.location.href,Hexo 生成的都是静态的页面,这个值也是正确的。

@iissnan
Copy link
Owner

iissnan commented May 10, 2016

噢,对了,你的问题可能是应该是 url 未配置导致的。url 未配置导致 page.permalink 拿到的值不正确,从而影响了 Disqus 的加载。

Please note that an absolute URL is required for the this.page.url variable. Using a relative URL for this variable may prevent Disqus from loading successfully on the page.

@forwardkth
Copy link
Author

好 谢谢答疑 :)

@forwardkth
Copy link
Author

加上站点配置文件 url 域名以后就正常了

@Mr-LiuDC
Copy link

我用的最新版 NexT.Pisces v5.1.3,正确配置了Disqus,也确定文章前部分的format正确,为什么有的文章可以正常加载显示出Disqus,而有些文章不能加载出Disqus。

@jeremykid
Copy link

我也是有一样的问题, 前面几篇文章的disqus 可以显示, 后面的文章不能加载disqus

@liian2018
Copy link

url配置ip可以吗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants