您可以使用Jekyll的_includes文件夹中的子目录吗?

wha*_*aes 5 html ruby jekyll gulp

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

_包括/页脚

_includes / heros

_includes / cta

等等...

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

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

这是否超出了预期的功能范围,还是我错过了一些东西?

小智 5

是的,您可以嵌套局部对象。子目录不必带有下划线。

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

_includes/footers
Run Code Online (Sandbox Code Playgroud)

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

{% include footers/footer1.html %}
Run Code Online (Sandbox Code Playgroud)