你能在Jekyll的_includes文件夹中使用子目录吗?

时间:2015-11-25 02:32:58

标签: html ruby gulp jekyll

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

_includes /页脚

_includes /英雄

_includes / CTA

等...

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

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

这是否超出了预期的功能,或者我错过了什么?

3 个答案:

答案 0 :(得分:4)

是的,你可以嵌套部分。子目录不必以下划线为前缀。

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

_includes/footers

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

{% include footers/footer1.html %}

答案 1 :(得分:1)

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

  • 您可以在_layout文件夹
  • 中使用子目录
  • 你不必使用下划线来工作(也许这只是一个最好的练习?)

答案 2 :(得分:1)

jekyll 3.0.1上,您不必使用__includes中添加目录。 我有一个类似_includes/foo/file.html, _includes/bar/file.html的结构,我使用{% include foo/file.html %}{% include bar/file.html %}。它完美无缺,没有下划线。这可能是其他版本的Jekyll中不存在的行为。