我在Lanyon上创建了我的网站,但是当我尝试配置disqus评论框时,它没有出现在网站上。
我做了以下更改:
_layouts / default.html中
<!DOCTYPE html>
<html lang="en-us">
{% include head.html %}
<body>
{% include google_analytics.html %}
{% include sidebar.html %}
<!-- Wrap is the content to shift when toggling the sidebar. We wrap the
content to avoid any CSS collisions with our real content. -->
<div class="wrap">
<div class="masthead">
<div class="container">
<h3 class="masthead-title">
<a href="{{ site.baseurl }}/" title="Home">{{ site.title }}</a>
<small>{{ site.tagline }}</small>
</h3>
</div>
</div>
<div class="container content">
{{ content }}
{% include comments.html %}
</div>
</div>
<label for="sidebar-checkbox" class="sidebar-toggle"></label>
<script>
(function(document) {
var toggle = document.querySelector('.sidebar-toggle');
var sidebar = document.querySelector('#sidebar');
var checkbox = document.querySelector('#sidebar-checkbox');
document.addEventListener('click', function(e) {
var target = e.target;
if(!checkbox.checked ||
sidebar.contains(target) ||
(target === checkbox || target === toggle)) return;
checkbox.checked = false;
}, false);
})(document);
</script>
</body>
</html>
_includes / comments.html
{% if page.comments %}
<!-- Add Disqus comments. -->
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'yathartha22-github-io'; // required: replace example with your forum shortname
var disqus_identifier = "{{ site.disqusid }}{{ page.url | replace:'index.html','' }}"
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
{% endif %}
这两个文件我在其中对disqus进行了更改以进行集成,但我无法得到它。任何人都可以帮助我。我甚至在每个帖子中都comments = true
。以下是我的博客link
答案 0 :(得分:0)
修复disqus评论包含在_includes/comments.html
:
{% if page.comments %}
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES * * */
var disqus_shortname = 'yathartha22-github-io' ;
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
{% endif %}
同样在index.html
中更改生成帖子链接的方式:
更改
<a href="{{ site.baseurl }}/{{ post.url }}">
到这个
<a href="{{ post.url | absolute_url}}">
Disqus评论不会出现在主页帖子列表中,但在每篇帖子中,所以在每个帖子中你都会看到评论框,例如这里http://localhost:4000/gsoc-preparation
或https://yathartha22.github.io/gsoc-preparation。