Using Assign with Filters - not working

I’m trying to list some filtered data entries:

{% assign posts = | where:“”,“category I want” %}
{% for post in posts limit:2 %}
{{ post.title }}
{% endfor %}

It works fine without the “where” filter - is it possible to filter on an assign like this? If not, is there another way to filter posts with a limit on the number of posts shown?

Yes you can use the where filter on an assign. Perhaps isn’t actually populated with anything. Do you have an example of the YAML you’re using in your posts _data file?

Sure, can’t seem to get the above code working with this yaml data, stored in a file called “posts.yaml” in the data folder:

- title: Cool Article
    name: category I want