使用3种不同布局的Jekyll index.html

使用3种不同布局的Jekyll index.html,jekyll,Jekyll,我有3种不同的布局 post-link.html post-article.html post-photo.html 我可以在index.html上显示我的所有文章,但它们都有相同的布局。是否可以在同一页面上显示多个布局(index.html)?一个页面只能有一个布局。你需要的是_include,你可以在任何显示帖子的地方使用它。一个页面只能有一个布局,但布局可以嵌套 我有三个\u布局: master.html default.html post.html master布局具有我想要的任

我有3种不同的布局

  • post-link.html
  • post-article.html
  • post-photo.html

我可以在index.html上显示我的所有文章,但它们都有相同的布局。是否可以在同一页面上显示多个布局(index.html)?

一个页面只能有一个布局。你需要的是_include,你可以在任何显示帖子的地方使用它。

一个页面只能有一个
布局,但布局可以嵌套

我有三个
\u布局

  • master.html
  • default.html
  • post.html
master
布局具有我想要的任何页面所需的所有基本结构。看起来 大概是这样的:

<html>
  <head>
    <title>{{ page.title }}</title>
  </head>
  <body>
    {{ content }}
  </body>
</html>
---
layout: master
---
<h1>
  {{ page.title }}
  {% if page.subtitle %}<small>{{ page.subtitle }}</small>{% endif %}
</h1>
{% if page.description %}<p>{{ page.description }}</p>{% endif %}
{{ content }}
---
layout: default
---
<p>Posted {{ page.date }}</p>
<ul>{% for tag in page.tags %}...{% endfor %}</ul>
{{ content }}
我对
\u posts
页面使用
post
布局。看起来是这样的:

<html>
  <head>
    <title>{{ page.title }}</title>
  </head>
  <body>
    {{ content }}
  </body>
</html>
---
layout: master
---
<h1>
  {{ page.title }}
  {% if page.subtitle %}<small>{{ page.subtitle }}</small>{% endif %}
</h1>
{% if page.description %}<p>{{ page.description }}</p>{% endif %}
{{ content }}
---
layout: default
---
<p>Posted {{ page.date }}</p>
<ul>{% for tag in page.tags %}...{% endfor %}</ul>
{{ content }}
---
布局:默认值
---
张贴{page.date}

    {%for page.tags%}…{%endfor%}
{{content}}
我写的每一篇博客文章都使用
post
布局,它们继承了所有三种布局

如果您想获得可重用标记的片段,那么我建议使用
.

我会调查的。似乎_include更多地用于页眉、页脚和侧边栏,但我会看看我能做些什么。谢谢你的建议。