PruitIgoe
PruitIgoe

Reputation: 6384

Jekyll - Include file to point to its own md file

If I include a file like so:

{% include_relative _layouts/tile.html %}

within my index.html file, how can I get tile.html to use the front matter of tile.md rather than index.md?

Upvotes: 0

Views: 25

Answers (1)

marcanuy
marcanuy

Reputation: 23982

It should be better to have the title in the config or a data file.

But in this case, if you want to access the frontmatter of any post/page you can do it by specifying the path where it is located as:

{%assign title_post = site.posts | where:"path","_posts/title.md" |first%}

{{title_post.title}}

Or if it is a page (as it seems to be) use site.pages instead of site.posts.

Upvotes: 1

Related Questions