Jekyll 杰基尔:我如何从位于子文件夹中的html中访问`_posts`?
\u pages/quant.htmlJekyll 杰基尔:我如何从位于子文件夹中的html中访问`_posts`?,jekyll,Jekyll,\u pages/quant.html => tree .... ├── 404.html ├── index.html ├── about.md ├── _config.yml ├── Gemfile ├── Gemfile.lock ├── _includes ├── _layouts ├── _pages │ ├── ai.html │ └── quant.html ├── _posts │ ├── 2017-01-09-daummovie-rxjs.md │ ├
=> tree
....
├── 404.html
├── index.html
├── about.md
├── _config.yml
├── Gemfile
├── Gemfile.lock
├── _includes
├── _layouts
├── _pages
│ ├── ai.html
│ └── quant.html
├── _posts
│ ├── 2017-01-09-daummovie-rxjs.md
│ ├── 2017-01-12-kage.md
│ ├── 2017-01-25-nomad.md
...
---
layout: board
permalink: /quant/
---
<ul id="post-list">
{% for post in paginator.posts %}
{% include item.html %}
{% endfor %}
</ul>
{% include pagination.html %}
---
布局:电路板
永久链接:/quant/
---
{paginator.posts%中的post为%s}
{%include item.html%}
{%endfor%}
{%include pagination.html%}
item.html
=> tree
....
├── 404.html
├── index.html
├── about.md
├── _config.yml
├── Gemfile
├── Gemfile.lock
├── _includes
├── _layouts
├── _pages
│ ├── ai.html
│ └── quant.html
├── _posts
│ ├── 2017-01-09-daummovie-rxjs.md
│ ├── 2017-01-12-kage.md
│ ├── 2017-01-25-nomad.md
...
---
layout: board
permalink: /quant/
---
<ul id="post-list">
{% for post in paginator.posts %}
{% include item.html %}
{% endfor %}
</ul>
{% include pagination.html %}
{post.tags%中标记的%s}
{%endfor%}
我想从\u页面
内的quant.html
访问\u posts
目录中的帖子
当我把quant.html放在页面外时,它会工作,但当我把文件放在页面内时,它就不工作了。。。。。我想如果我把html
文件放在子文件夹中,它就不能识别paginator
上面的quant.html
代码不显示任何帖子
我怎样才能得到所有的帖子呢?对不起,这个问题没有多大意义。请重构它。我认为您要么希望将当前帖子从for循环发送到include,要么简单地列出帖子标题(或类似的内容)。目前,for循环除了输出item.html include文件中包含的内容外,没有做任何事情。我假设您的include文件需要post对象来处理它。对吧? 如果是这样,您需要将
post
发送到include,然后从item.htmlinclude
中检索它
要将post
发送到item.html
:
<li class="post-item post {{ post.post_class }}">
<a href="{{ post.url }}">
<h3 class="post-title">{{ post.title }} <post class="post-date"> ({{ post.date | date: '%Y-%m-%d %H:%M' }})</post></h3>
<p class="post-excerpt">{{ post.excerpt | strip_html | truncatewords: 75 }}</p>
</a>
<p class="post-tags">
{% for tag in post.tags %}
<a href="{{ site.baseurl }}/tags/{{ tag }}" title="{{ tag }}"
class="tag tag-{{ tag }}">{{ tag }}</a>
{% endfor %}
</p>
<!--<div class="clearfix"></div>-->
</li>
{% for post in paginator.posts %}
{% include item.html item = post %}
{% endfor %}
然后,要获取在item.html
中使用的post
:
<li class="post-item post {{ post.post_class }}">
<a href="{{ post.url }}">
<h3 class="post-title">{{ post.title }} <post class="post-date"> ({{ post.date | date: '%Y-%m-%d %H:%M' }})</post></h3>
<p class="post-excerpt">{{ post.excerpt | strip_html | truncatewords: 75 }}</p>
</a>
<p class="post-tags">
{% for tag in post.tags %}
<a href="{{ site.baseurl }}/tags/{{ tag }}" title="{{ tag }}"
class="tag tag-{{ tag }}">{{ tag }}</a>
{% endfor %}
</p>
<!--<div class="clearfix"></div>-->
</li>
{% for post in paginator.posts %}
{% include item.html item = post %}
{% endfor %}
#_include/item.html
这是帖子:{{include.item}
我想你没有领会我的观点(或者我的帖子没有那么明显)。。。当我把quant.html
放在\u页面
中时,它会工作,但当我把该文件放在\u页面
中时,它就不工作了。。。。。我想如果我把html
文件放在子文件夹中,它就不能识别paginator
…我添加了item.html
,所以也要检查它item.html
不知道post
变量是什么!:)根据我的回答,你必须将post
变量发送给它。我知道了它不起作用的原因:(“不要设置永久链接!在你的博客页面前面设置永久链接会导致分页中断。只需忽略永久链接”)感谢更新。如果有效,请将问题标记为已回答。