Using include_relative to import markdown in collection page

Hi,

I’m trying to build a team page, with a collection ‘team’ and each team member having a folder in the collection dir. Inside these folders, each member has a main page.md with metadata in the front matter.
This main page should now include different (localized) markdowns from the same folder. I’ve tried to use
{% include_relative test.html %} but this neither works for .html nor for .md files.
The exception I get is:
Liquid Exception: Could not locate the included file 'test.html' in any of ["<jekyll_folder>/_team/<person1>/page.md"]

What am I doing wrong?

@ptoews If I understand your use-case properly, then your directory structure should be something like this:

_config.yml
_team/
  ashmaroli/
    page.md
    test.md

And ashmaroli/page.md should be the file containing {% include_relative test.md %}

Exactly. I probably should have written that down like you did

I got no errors from that setup and jekyll-3.8.4. So, something’s amiss elsewhere…
What version of Jekyll are you using…?

1 Like

Thank you for verifying that this scenario is legit and include_relative should work :grin: I checked other parts of the code now and found my mistake. I’m using 3.8.4 as well.

The mistake was this snippet in an overview page that looped over all team members:

{% for person in site.team %}
  <script>console.log({{ person | jsonify }})</script>
{% endfor %}

I guess that somehow the jsonify printed out that relative include in the context of this overview page which caused the exception.

Glad you were able to resolve the issue.

1 Like