What is the best way to index a selection of posts from different collections?
The goal is to create a home page with a preview of a few pages from unrelated collections.
That is easy to do with posts, using categories or custom variables like here:
{% assign posts = site.posts | where_exp: "post", "post.categories contains 'portfolio'" %}
{% for post in posts %}
But it doesn’t work with collections the same way.
{% for collection in site.documents %} returns all posts and all collections, no idea how to limit and sort them then.
That sorts and brings all the collections, and not the posts. Perfect!
Now the question becomes, how to sort further through only certain posts in those collections that contain a custom variable, for instance. Now that doesn’t work with the same logic it works with posts.