Pagination URL is not changing in the collection page

On clicking the next item in pagination,it remains in the same page.

For eg: I clicked 2nd page in the collection it returns the page appropriately.But if I click 3rd or 4th item it remains in the 2nd page itself.Also in the url it appends page=4&page=3&page=2 and so on!

I checked all the href in the inspector, all tags are returning to the same URL.

Basically if I click page 3, page 2 should be cleared and page=3 should be appended but its not happening, the page number gets appended in the url bar accroding to the click.

Here is my pagination code

{% comment %}
Renders a set of links for paginated results. Must be used within paginate tags.

Usage:
{% paginate results by 2 %}
{% render ‘pagination’, paginate: paginate, anchor: ‘#yourID’ %}
{% endpaginate %}

Accepts:

  • paginate: {Object}
  • anchor: {String} (optional) This can be added so that on page reload it takes you to wherever you’ve placed your anchor tag.
    {% endcomment %}
{{ 'component-pagination.css' | asset_url | stylesheet_tag }}

{%- if paginate.parts.size > 0 -%}

    {%- if paginate.previous -%}
  • {% render 'icon-caret' %}
  • {%- endif -%}

    {%- for part in paginate.parts -%}

  • {%- if part.is_link -%} {{ part.title }} {%- else -%} {%- if part.title == paginate.current_page -%} {{ part.title }} {%- else -%} {{ part.title }} {%- endif -%} {%- endif -%}
  • {%- endfor -%}

    {%- if paginate.next -%}

  • {%- render 'icon-caret' -%}
  • {%- endif -%}
{%- endif -%}

I’m using dawn theme and before it was infinite scroll in the collections.I’m trying to change back it to pagination.

Please help

Hi Community,

Please help with any solutions