Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you use subdirectories within Jekyll's _includes folder?

My plan is to have folders within the _includes directory:

_includes/footers

_includes/heros

_includes/cta

etc...

When I reference that {% include footers/footer1.html %} I get the following error:

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

Is this outside the intended functionality, or am I missing something?

like image 445
whatsnewsaes Avatar asked Nov 25 '15 02:11

whatsnewsaes


3 Answers

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 %}
like image 134
Bryan Schuetz Avatar answered Sep 18 '22 03:09

Bryan Schuetz


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.

like image 27
georger Avatar answered Sep 19 '22 03:09

georger


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?)
like image 24
whatsnewsaes Avatar answered Sep 21 '22 03:09

whatsnewsaes