I want to create a page on my Jekyll site that lists all posts belonging to a specific category, for example, 'tutorials'. How do I assign a category to a post using front matter? What Liquid variable would I use to access all posts, and how would I filter them to display only those from the 'tutorials' category on a page?
Navigate to 'https://jekyllrb.com'. Click on the 'Docs' link. Navigate to the 'Posts' section (under 'Content') to understand how posts are structured and categorized. Navigate to the 'Front Matter' section (under 'Content') to find out how to assign categories to posts. Navigate to the 'Variables' section (under 'Site Structure') to find the Liquid variable for accessing all posts. Navigate to the 'Liquid' section (under 'Site Structure') to understand how to apply filters for displaying specific categories. Synthesize the information to explain how to assign categories, access posts, and filter them by category using Liquid.
The agent correctly states that categories are assigned in the post's front matter using the `categories` key (e.g., `categories: [tutorial, jekyll]`). The agent correctly identifies that the `site.posts` Liquid variable is used to access all posts. The agent demonstrates an understanding of how to filter posts by category, either by suggesting a Liquid filter (e.g., `where` or `group_by`) or by explaining iteration with a conditional check (e.g., `{% for post in site.posts %}{% if post.categories contains 'tutorials' %}`). The agent explains how to display the filtered posts (e.g., by iterating through them in a `for` loop and outputting their titles and links).