Pagination with rel=”next” and rel=”prev” in Magento 2

2How to Add Rel Prev, Next tag in Magento 2

Magento 2 has numerous options that can help to optimize the search engine optimization but when it comes to category pages, you have only option to add canonical meta tags.

In this , we will add our own variation of canonical tag and by adding rel=”next” and rel=”prev” tags to help bots with paginated content.

Following are the steps for implementation:

Step 1 : Create and configure the module to view specific events

Create a registration.php in app/code/Bay20/RelPage directory. Here Bay20 is vendor name and RelPage is module name.


Create a module.xml in app/code/Bay20/RelPage/etc directory. copy and paste the following snippet

<?xml version="1.0"?>
<config xmlns:xsi=""
    <module name="Bay20_RelPage" setup_version="1.0.0"/>

Now enable the module by running the command

php bin/magento module:enable Bay20_RelPage

After doing this, you need to do this is to configure module with specific events. For that, you need to create events.xml in app/code/Bay20/RelPage/etc/frontend directory then create observer class.

<?xml version="1.0"?>
<config xmlns:xsi="" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="layout_generate_blocks_after">
        <observer name="categorySeo" instance="Bay20\Seo\Observer\Category" />

Please contact us at or call us at +91-8800519180 for any support related to Magento 2. You can also visit the Magento2 development page to check the services we offer.