简体   繁体   中英

jekyll filename for current file

The title says it all. Is there a way to access the current filename in Jekyll? Before you jump the gun and try to mark it as duplicate, keep in mind that I'm asking for the current filename, not for the generated filepath which can be access by page.url.

As an example, lets say that there is a file1.html which include file2.html. I want to be be able to get file1.html if I'm inside file1.html and file2.html vice-versa. page.path only returns the filename for the generated file as in I will get file1.html even from within file2.html.

A concrete example:

file2.html:

<div>
{{ page.name }}
</div>

file1.html:

<div>
{% include file2.html %}
</div>

index.html:

{% include file1.html %}

rendered:

<div>
  <div>
    index.html
  </div>
</div>

Instead of index.html, I want it to return file2.html

Thanks

Edit : An include is just a fragment that is inserted into a page. Once every include are made, the page is then processed as a single block of code.

There is no way to get any info from liquid about an include name.b

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM