Display entries by category (multiple categories) I would like to know how I can create a page that contains all entries from a section e.g. 'news'. I want to divide the entries by their given category. 

News (section)

Category 1:


entry in category 1
second entry in category 1
third entry in category 1


Category 2:


entry in category 2
second entry in category 2
third entry in category 2


etc. 

Does anyone know the code for this? The categories are all in the same category group.
You can use .relatedTo(category)

{% for category in craft.categories.group('categoryName') %}
  &lt;h2&gt;{{category.title}}&lt;/h2&gt;
  {% for entry in craft.entries.section('news').relatedTo(category) %}
    &lt;a href="{{entry.url}}"&gt;{{entry.title}}&lt;/a&gt;&lt;br&gt;
  {% endfor %}
{% endfor %}


You can check for length if you don't want to show categories which aren't related to any entry.

See the relations documentation