Jekyll - 包含文件指向它自己的 md 文件
Jekyll - Include file to point to its own md file
如果我像这样包含一个文件:
{% include_relative _layouts/tile.html %}
在我的 index.html 文件中,如何让 tile.html 使用 tile.md 而不是 index.md 的前面内容?
最好在配置中包含 title 或 data 文件。
但在这种情况下,如果你想访问任何 post/page 的 frontmatter,你可以通过指定它所在的路径来实现:
{%assign title_post = site.posts | where:"path","_posts/title.md" |first%}
{{title_post.title}}
或者如果它是一个页面(看起来是),请使用 site.pages
而不是 site.posts
。
如果我像这样包含一个文件:
{% include_relative _layouts/tile.html %}
在我的 index.html 文件中,如何让 tile.html 使用 tile.md 而不是 index.md 的前面内容?
最好在配置中包含 title 或 data 文件。
但在这种情况下,如果你想访问任何 post/page 的 frontmatter,你可以通过指定它所在的路径来实现:
{%assign title_post = site.posts | where:"path","_posts/title.md" |first%}
{{title_post.title}}
或者如果它是一个页面(看起来是),请使用 site.pages
而不是 site.posts
。