I have an directory called /patterns
in my Jekyll site, whose structure generally looks generally like this:
_includes
_layouts
_site
/patterns
index
You can choose to include file fragments relative to the current
file by using the include_relative
tag for your
/patterns/file.html
For the directory structure you have:
_includes
_layouts
_site
/patterns/file.html
index.html
In this case the following doesn't work:
{% include /patterns/file.html %}
Use include_relative
as /pattern
is relatif to index.html
as the current file
:
{% include_relative patterns/file.html %}
Note:
You can't use the include_relative
tag with any files inside your layouts folder. You can only use include_relative
on a page or post. Layouts code is executed in the context of page/post rendering and the include_relative is calculated relative to this page or post, not from the layout itself.
In this case your code on index.html
shall be:
---
layout: null
---
(put all code from _layouts/default.html)
{% include_relative patterns/file.html %}