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

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

_includes /页脚

_includes /英雄

_includes / CTA

等等…

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

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

这是在预期的function之外,还是我错过了什么?

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

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

 _includes/footers 

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

 {% include footers/footer1.html %} 

这是我回到它的那些场景之一,似乎尝试了完全相同的东西,并且它起作用了。


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

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