Is it possible to use same template for index and archive template? I'm new to Craft from ExpressionEngine and wondered how people handle Month/Year archive pages.  I have figured out how to get the archives to display but the code seems overly complex.  I wondered if there is a more straightforward approach or if it is possible to display your archive using the same template as the news/index  which displays all. In EE this was possible and just wondered if it was in Craft.

Thanks in advance.  My archive template code below.

{% if month is not defined %}
    {% set before = year + 1 %}
    {% set after  = year %}
{% else %}
    {% if month == 12 %}
        {% set yearBefore = year + 1 %}
        {% set monthBefore = '01' %}

        {% set before = yearBefore~'-'~monthBefore %}
        {% set after = year~'-'~month %}
    {% else %}
        {% set before = year ~ '-' ~ (month + 1) %}
        {% set after  = year ~ '-' ~ month %}
    {% endif %}
{% endif %}

{% set allEntries = craft.entries.section('news').limit(null).after(after).before(before) %}

{% for date, entries in allEntries | group("postDate|date('F Y')") %}
    &lt;h3&gt;Entries from {{ date }}&lt;/h3&gt;

    {% for entry in entries %}
        &lt;article class="post"&gt;
            {% for asset in entry.newsthumb %}
                &lt;div class="image-wrapp"&gt;
                    &lt;a href="{{ entry.url }}"&gt;&lt;img src="{{ asset.url('newsthumb') }}" alt="{{ asset.title }}"&gt; &lt;/a&gt;
                &lt;/div&gt;
            {% endfor %}

            &lt;div class="text-wrapp"&gt;
                &lt;h3&gt;&lt;a href="{{ entry.url }}"&gt;{{ entry.title }}&lt;/a&gt;&lt;/h3&gt;

                &lt;time datetime="2017-07-27" class="post-time"&gt;{{ entry.postDate.format('F d, Y') }} &lt;/time&gt;

                {{ entry.newssummary }}

                {% if entry.newscategory | length %}&lt;ul class="category-list"&gt;{% endif %}
                {% nav category in entry.newscategory %}
                    &lt;li&gt;&lt;a href="{{ category.url }}"&gt;{{ category.title }}{{ not loop.last ? ', ' }}&lt;/a&gt;&lt;/li&gt;
                {% endnav %}

                {% if entry.newscategory | length %}&lt;/ul&gt;{% endif %}
            &lt;/div&gt;
        &lt;/article&gt;
    {% endfor %}
{% endfor %}
The way I do this is to use a different template for each set of entries. So there would be an archive one for all the articles from a given month: _news/index-archive, and a category one for all the articles in a given category: _news/index-category, and one for all of the entries: _news/index-all, maybe one for articles by tag, etc.

Each of these templates sets entries to the relevant entries, and then does

{% include '_news/index-generic' with {
  entries: entries
} only %}


And index-generic has all the shared display code.

Probably there will be a couple of other things that vary as well, for example a heading:

{% include '_news/index-generic' with {
  entries: entries,
  heading: 'Category: '~category.title
} only %}