Can you use subdirectories within Jekyll's _includes folder?

被刻印的时光 ゝ 提交于 2019-12-05 08:34:20
Bryan Schuetz

Yes you can nest partials. Subdirectories don't have to be prepended with an underscore.

Let's say you have a footers folder inside the _includes folder.

_includes/footers

You could include your resources by adding the relative path:

{% include footers/footer1.html %}

This is one of those scenarios where I came back to it, seemingly tried the exact same thing, and it worked.


  • You can use subdirectories within _layout folders
  • You don't have to use underscores for it to work (Perhaps this is just a best, practice?)

On jekyll 3.0.1 you don't have to use _ to prepend directories in _includes. I have a structure like _includes/foo/file.html, _includes/bar/file.html and I use it like {% include foo/file.html %} and {% include bar/file.html %}. It works perfectly fine without underscores. This might be a behavior that is not present in other versions of Jekyll.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!