0
votes

I'm trying to grab a specific item from a collection called 'content' based on an id using where_exp, but for the life of me I can't get it to work. Here's the code:

filter:

{% assign var = site.content | where_exp:"content", "content.id == 'testId'" | first %}

frontmatter for post in collection:

---
layout: content
title: "This is the title"
image: "assets/photos/image.jpg"
id: "testId"
---

html:

<img class="full-width-poto" src="{{ var.image }}"> 

I can't figure out what I'm doing wrong.

Note, I've been referring to this post: Getting a specific item from a collection in Jekyll and https://riptutorial.com/jekyll/example/28446/accessing-a-specific-collection-item

1

1 Answers

0
votes

Ok, I figured out my problem, just in case someone comes across this. For some reason I can't use the key 'id' for this...it must be hardcoded for something else.

I swapped in 'myid' and it works fine now...