How To

Add Pagination To URL

2min



There are times when it is beneficial to have the users selected pagination captured and stored as part of the URL.

For Example :

  • Allow for consistent tracking of the selected page of results.
  • Reusable 'landing page' links
  • SEO

To accomplish this we will add in a custom override module that will:

  1. Intercept the outgoing query
  2. Analyze the existing URL string
  3. Update the localstorage of selected page value
  4. Apply the page offset to the outgoing query
  5. Update the existing URL string

See : Custom Overrides for details on preparing for Klevu JS overriding

Template JS Override

Add the supporting module addPaginationToURL and apply it to the landing page override.

Note : the same addPaginationToURL module can be used on Category pages by applying the override to the catnav scope as well.

Full Example

JavaScript