如何在Jekyll / Liquid中引用帖子的全部内容(包括布局)

时间:2016-03-23 13:29:27

标签: jekyll liquid github-pages

我正在使用Jekyll(3.0+),我有index.html

---
layout: mylayout
---
<div>
  {{ site.posts[0].content }}
</div>

正如您所看到的,我只想显示第一篇帖子,_layouts/mylayout.html是:

<article itemtype="http://schema.org/BlogPosting">
  <header>
    <h1>{{ page.title }}</h1>
  </header>
  <div>
    {{ content }}
  </div>
</article>

不包括布局

问题是我看不到mylayout.html的包装结构,我只能看到内容降价翻译!所以,我原以为:

<article itemtype="http://schema.org/BlogPosting">
  <header>
    <h1>Page title</h1>
  </header>
  <div>
    <section>My post paragraph</section>
    <p>Hello, this is my post.</p>
  </div>
</article>

但我得到了这个:

<div>
  <section>My post paragraph</section>
  <p>Hello, this is my post.</p>
</div>

我如何参考整个页面?

1 个答案:

答案 0 :(得分:0)

看起来我需要使用output属性:

---
layout: mylayout
---
<div>
  {{ site.posts[0].output }}
</div>

这基本上会返回整个HTML,包括模板!