Craft entries related on a category page So i'm trying to output blog entries related to a category.


I first created a category group ('categories')
I added several categories to the group ('innovation', 'teams', etc)
I added a category field to my blog post matrix field (post.category)
On my blog index page (example.com/blog) I have excerpts of posts and a sidebar which has the categories and their urls

 {% set categories = craft.categories.group('categories') %}

 {% for category in categories %}
 &lt;li&gt;&lt;a href="{{ category.url }}"&gt;{{ category.title }}&lt;/a&gt;&lt;/li&gt;
 {% endfor %}

When I click on the link it goes to the page I expect (example.com/categories/teams) and is using the template i specified for the template group (categories.html)
In the template for the category I can list the title and name but I want to get the entries so I:

&lt;h1&gt;{{ category.title }}&lt;/h1&gt; &lt;--- just this works
{% set posts = craft.entries.relatedTo(category) %}
{% for post in posts %}
&lt;p&gt;{{ post.title }}&lt;/p&gt;
{% endfor %}



But this didn't work

following http://buildwithcraft.com/help/entries-related-to-category


then I tried this, thinking specifying the field was necessary

&lt;h1&gt;{{ category.title }}&lt;/h1&gt; &lt;--- again, this works
{% set posts = craft.entries({
section: 'blog',
relatedTo: {
targetElement: category,
field: 'posts.categories'
}
}) %}

{% for post in posts %}
&lt;p&gt;{{ post.title }}&lt;/p&gt;
{% endfor %}



and this doesn't work either. 

Anyways, i'm not sure where I am going wrong and any help would be appreciated.
I should note that the relatedTo method accepts a CategoryModel, not the title of a category. What you ended up doing works, but here's the way to do with the relatedTo method, which is what I'd suggest for anyone finding this in the future:

{% for entry in craft.entries.relatedTo(craft.categories.slug('your-cat-slug')) %}

You now have all entries that are associated with the given category, and can loop through them with the usual {% for entry in entries %} technique.

TL;DR: You can't pass the category name. You have to give relatedTo an actual CategoryModel.