使用 Jekyll,如何在非 post 或页面的布局中 organize/place 段落数据?

Using Jekyll, how to organize/place paragraph data within layout that is not post or page?

使用 Jekyll 的第一天,我基本上拥有 Jekyll 的最小主题,我正在修改它以尝试创建一个新站点。

我在 _layouts 中有一个 home.html。我的目标是将段落放在 3 个单独的列中,side-by-side。我的理解是 _layouts 和 _includes 主要是为了格式化,至少我是这么看的。我知道可以在这些文件中放置一堆静态文本来显示,但如果要显示的文本位于类似 _pages 文件夹中,它看起来更干净(也更容易编辑)。但这样做当然会在 header 中创建一个新的 link。所以我试图找到一种方法来插入一个降价文件,它只是我可以干净地插入到我的主页中的文本段落,而且只能插入到那里。

为了插入布局或包含的唯一目的,如何以及在何处放置降价(段落大小),而不是将它们直接写入布局或包含,也不会使其成为 post 或页面,或使用 _data 中的变量。我希望制作一个降价文件,用于比 posts、页面等更小的目的...

我的 _layouts/home.html 看起来如下,但没有显示降价。 IIRC,这是因为 includes 只能访问 _includes,我希望不必在 _includes 或 html 中写入此数据。

---
layout: default
---

<div class="home">
    <div class="home-col-wrapper">
        <div class="home-col home-col-1">
            {% include front-col-1.md %}
        </div>
    </div>

    <div class="home-col home-col-2">
            {% include front-col-2.md %}
        column 2
    </div>

    <div class="home-col home-col-3">
            {% include front-col-3.md %}
        column 3
    </div>
</div>

我也试过在_pages里放一个*.md文件,把布局改成home,但是没有用。文本未显示在主页布局中。

---
layout: home
---

A bunch of stuff should probably go here. So be sure to make sure it looks ok. ok? ok! 

我刚刚做了类似的事情。如果我理解正确你的问题,你需要做的就是将 {% include front-col-1.md %} 替换为

{% capture temp %}{% include front-col-1.md %}{% endcapture %}
{{ temp  | markdownify }}

发生的事情是 Liquid 在变量 temp 中捕获 markdown 文件,然后 markdownify 将其转换为 HTML 并添加它。

我认为您不能将 markdown 文件放在其他地方,但它们需要放在 _includes 中。

相关:https://github.com/jekyll/jekyll-help/issues/51