【问题标题】:Jekyll 3 not picking up custom collection in includeJekyll 3 没有在 include 中选择自定义集合
【发布时间】:2019-07-31 00:42:15
【问题描述】:

我有一个简单的 jekyll 网站,我正在从 jekyll 模板开发。我正在努力让它在 netlifycms 中可编辑。

我已将集合移至自定义目录 customcollections,已在 _config.yml 中指定此内容,并将 _posts 目录移至其中。这很好用。

然后我从包含/组件中包含一个组件,以拉入并遍历自定义集合 _navtiles。

由于某种原因,当我尝试遍历导航块时:

<div class="features">
        <h3>---NAVTILES</h3>
    {% for navtile in site.navtiles %}
        <section class="post">
            <span class="image"><img src="{{ site.baseurl }}{{ navtile.image }}" alt="" /></span>
            <div class="content">
                <h3>{{ navtile.title }}</h3>
                <p>{{ navtile.body | remove: "<p>" | remove: "</p>" }}</p>
                {% if navtile.url %}
                    <ul class="actions">
                        <li><a href="{{ navtile.url }}" class="button">More</a></li>
                    </ul>
                {% endif %}
            </div>
        </section>
    {% endfor %}
</div>

它不会拉入 customcollections/_navtiles/ 中存在的 navtile 集合对象

但是,如果我将 site.navtiles 更改为 site.posts,那么它会非常高兴地拉入所有博客文章。

谁能告诉我我做错了什么? 网站在这里: index.html - https://github.com/tofuwarrior/sites-clearspringacupuncture/blob/master/index.html

_config.yml - https://github.com/tofuwarrior/sites-clearspringacupuncture/blob/master/_config.yml

_includes/components/navtiles.html - https://github.com/tofuwarrior/sites-clearspringacupuncture/blob/master/_includes/components/navtiles.html

组件被愉快地拉入到 index.html 中。

网站预览在这里: http://dev.clearspringacupuncture.co.uk/

我很困惑,因为它可以很好地与 _posts 配合使用 谁能指出我正确的方向 谢谢。 杰基尔

【问题讨论】:

    标签: jekyll


    【解决方案1】:

    您只需要为您的自定义集合配置 Jekyll。

    在 _config.yml 中:

    collections:
      navtiles:
    

    documentation

    【讨论】:

    • 如此明显:-) - 感谢一百万。我忘记了 admin/config.yml 不会影响主要的 jekyll 构建。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-04-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-14
    • 1970-01-01
    • 2018-10-10
    相关资源
    最近更新 更多