Jekyll如何将内容添加到多个位置

Jekyll如何将内容添加到多个位置,jekyll,Jekyll,如何在一个布局文件中创建多个{content}}。像这样的 _布局>default.html <html> <body> <H2>summary</H2> <p> {{content:summary}} </p> <H2>detail</H2> <p> {{content:detail}} </p> </body> </

如何在一个布局文件中创建多个{content}}。像这样的

_布局>default.html

<html>
<body>
  <H2>summary</H2>
  <p>
    {{content:summary}}
  </p>
  <H2>detail</H2>
  <p>
    {{content:detail}}
  </p>
</body>
</html>

总结

{{内容:摘要}

细节 {{content:detail}

index.html

----
layout: default
----
content:summary
<b>show superhero</b>

content:detail
<b>Spiderman Batman Spiderman</b>
----
布局:默认值
----
内容:摘要
表演超级英雄
内容:细节
蜘蛛侠蝙蝠侠蜘蛛侠
输出

<html>
<body>
  <H2>summary</H2>
  <p>
    <b>show superhero</b>
  </p>
  <H2>detail</H2>
  <p>
    <b>Spiderman Batman Spiderman</b>
  </p>
</body>
</html>

总结

表演超级英雄

细节 蜘蛛侠蝙蝠侠蜘蛛侠


Jekyll只支持一个内容区。您仍然可以使用技巧获得示例中所示的结果

只需将摘要放在页面的YAML首页:

index.html …并将其显示在布局文件中,如下所示:

<html>
<body>
  <H2>summary</H2>
  <p>
    This is the summary
  </p>
  <H2>detail</H2>
  <p>
    This is the content
  </p>
</body>
</html>
_layouts/default.html

总结

{{page.summary}}

细节 {{content}}

输出如下所示:

<html>
<body>
  <H2>summary</H2>
  <p>
    This is the summary
  </p>
  <H2>detail</H2>
  <p>
    This is the content
  </p>
</body>
</html>

总结

这是总结

细节 这就是内容

Hi:-)我在变量后面添加“|”,以便于添加HTML标记
<html>
<body>
  <H2>summary</H2>
  <p>
    This is the summary
  </p>
  <H2>detail</H2>
  <p>
    This is the content
  </p>
</body>
</html>