0
votes

How can I use the include_relative tag correctly?

I have my folder layout and files like so.

my-account.html

  • _includes
    • page-content
      • my-account
        • my-account.html
        • header.html
        • nav.html

In my-account.html I include the following file.

{% include page-content/my-account/my-account.html %}

All good.

However, inside the my-account.html from the includes folder, I am also calling header.html and nav.html

{% include page-content/my-account/header.html %}

{% include page-content/my-account/nav.html %}

Is there a way to use include_relative like this from the my-account.html since its in the same folder?

{% include_relative header.html %}

{% include_relative nav.html %}

Currently I get the error:

'./header.html' not found, so obviously the include_relative is not working.

Thanks!

1
Did you try just {% include header.html %} and {% include nav.html %} for the last ones?Virtua Creative
Yeah tried that but when you use the {% include %} tag, it goes to the root of the include folder, so it says header and nav not found.Rhys

1 Answers

0
votes

Try this to the file my-account.html:

{% include /page-content/my-account/header.html %}
{% include /page-content/my-account/nav.html %}

I've tested here with a similar structure and worked, then you should be ok. ;)