无法在我的网站上获得 disqus 评论部分(jekyll)
Not able to get disqus comments secton on my website(jekyll)
我在 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 而进行更改的两个文件,但我无法获取它。谁能帮帮我。我什至在每个 post 中取得了 comments = true
。这是我博客link
修复 _includes/comments.html
中包含的 disqus 评论:
{% 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
中,将生成链接的方式更改为 posts:
改变
<a href="{{ site.baseurl }}/{{ post.url }}">
至此
<a href="{{ post.url | absolute_url}}">
Disqus 评论不会出现在主页 post 列表中,但会出现在每个 post 列表中,因此在每个 post 中您会看到评论框,例如这里 http://localhost:4000/gsoc-preparation
或 https://yathartha22.github.io/gsoc-preparation.
我在 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 而进行更改的两个文件,但我无法获取它。谁能帮帮我。我什至在每个 post 中取得了 comments = true
。这是我博客link
修复 _includes/comments.html
中包含的 disqus 评论:
{% 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
中,将生成链接的方式更改为 posts:
改变
<a href="{{ site.baseurl }}/{{ post.url }}">
至此
<a href="{{ post.url | absolute_url}}">
Disqus 评论不会出现在主页 post 列表中,但会出现在每个 post 列表中,因此在每个 post 中您会看到评论框,例如这里 http://localhost:4000/gsoc-preparation
或 https://yathartha22.github.io/gsoc-preparation.