Directly access content of specific collection item


#1

If I have a collection named _code, and a file in there named survivors.html, how can I get the content of that file in another page (without looping)?

I thought {{ site.code.survivors.content }} would work but it doesn’t. The collection works fine, I can loop thru and get what I want but seems like I should be able to directly access the content of a specific file if I know the filename.


#2

Does the following work for you?

{% assign survivor = site.code | where: 'path', "_code/survivors.html" %}
{{ survivor.content }}

#3

yes, that is more or less what I am doing, just thought I could do it directly.

Thanks for confirming.