【问题标题】:Can you use subdirectories within Jekyll's _includes folder?你可以使用 Jekyll 的 _includes 文件夹中的子目录吗?
【发布时间】:2015-11-25 02:32:57
【问题描述】:

我的计划是在_includes 目录中包含文件夹:

_包含/页脚

_包括/英雄

_includes/cta

等等……

当我引用 {% include footers/footer1.html %} 时,我收到以下错误:

Liquid Exception: Included file '_includes/footers/footer1.html' not found in _layouts/default.html

这超出了预期的功能,还是我遗漏了什么?

【问题讨论】:

  • 这应该可以工作。你在 github 上有一些资源吗?
  • 这对我有用!检查文件权限并确保文件_includes/footers/footer1.html在那里。

标签: html ruby gulp jekyll


【解决方案1】:

是的,您可以嵌套部分。子目录不必在前面加上下划线。

假设您在_includes 文件夹中有一个footers 文件夹。

_includes/footers

您可以通过添加相对路径来包含您的资源:

{% include footers/footer1.html %}

【讨论】:

    【解决方案2】:

    在jekyll 3.0.1 上,您不必使用_ 在_includes 中添加目录。 我有一个像_includes/foo/file.html, _includes/bar/file.html 这样的结构,我像{% include foo/file.html %} 和{% include bar/file.html %} 一样使用它。它工作得很好,没有下划线。这可能是其他版本的 Jekyll 中不存在的行为。

    【讨论】:

      【解决方案3】:

      这是我回到它的场景之一,似乎尝试了完全相同的事情,并且成功了。


      • 您可以使用 _layout 文件夹中的子目录
      • 您不必使用下划线来使其工作(也许这只是一种最佳做法?)

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-02-05
        • 2021-12-04
        • 2011-02-02
        • 1970-01-01
        • 2021-07-16
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多