Can't Output Entries from Particular Blog Categories Trying to get all entries related to a particular blog category to output to the page. Right now I just get the correct URL for any category and a blank page. 

Also my categories are entered into a matrix field as one of the matrix blocks. I use a single matrix field to capture all of the content for each blog entry.

Here is my categories/_category.html template code.

{# Fetch all of the entries related to this category #}
{% set category = craft.categories.slug('') %}
{% set entries = craft.entries.relatedTo(category) %}

{# Output them #}
{% for entry in entries %}
    &lt;a href="{{ entry.url }}"&gt;{{ entry.title }}&lt;/a&gt;
{% endfor %}


I've tried plugging in particular category slugs into the craft.categories.slug('') but no help. I'm following advice from https://craftcms.com/support/entries-related-to-category

....and

Category Entries

Any ideas on what is missing?
First you'll need to know what you are currently doing

craft.categories.slug()


Will return a CategoryQuery with no property attached to it. So when you execute this query you'll fetch all categories. Your so called category variable is no category but a query that needs to be executed in order to do something

craft.entries.relatedTo(category)


Same thing again: it will return an EntryQuery with all entries that related to any category in any field. So as long as an entry has a relation to what every category it will match. Then again entries is not an array of entries but a query that needs to be executed via all()

When you loop through this query it is executed as well but with a deprecated warning because this way is not supported anymore.

If you are in a category page you'll likely have the catetory variable already injected as superglobal in your template. So there is already a category you have access to.

You can then do

{% for entry in craft.entries.relatedTo(category).all() %}


Please make sure there are entries that are related to your current category