I have a blog listing page which works correctly. I also have categories that I would like to use the same template rather than creating a whole new template since the design is exactly the same.
However when I set the category template to blog/index
the page loads correctly but doesn't limit by categories.
Looking at my simplified template code, I'm not sure how to get it to display only the category being viewed or all if on the blog index page.
My urls are
/blog/
/blog/p2 (pagination)
/blog/{{ slug }}
I would like the following url's to use the same template code:
/blog/category/{{ category_url }}
/blog/category/{{ category_url }}/p2
My template code:
{% paginate craft.entries.section('blog').limit(6) as pageInfo, pageEntries %}
{% for entry in pageEntries %}
<article class="col-sm-6 block" data-mh="blog-rows">
some code
<aside>
more code
</aside>
<a href="{{ entry.url }}" class="btn btn-primary">Keep Reading</a>
</article><!--block-->
{% endfor %}
If necessary I can create a category.html
template, but then I'd essentially have duplicate code. Is there a way to do what I want to?