Hello Magento Friends,

In today’s blog, we will learn about How to Skip Categories from Breadcrumbs on the Category Page in Magento 2.

Breadcrumbs in Magento 2 serve as a navigational aid for users to understand their current location within the site’s hierarchy. They are particularly important on category pages, where users often want to move up the category tree to view similar products.

Magento 2 Breadcrumbs Extension can help you to easily show breadcrumbs on product pages and improve the navigational experience of customers.

By default, Magento 2 includes all parent categories in the breadcrumb path, which can sometimes create a lengthy and less user-friendly breadcrumb trail. In this blog post, we will discuss how to modify the Magento 2 breadcrumb functionality to skip certain categories and create a cleaner and more concise breadcrumb trail for users.

Why Skip Categories in Breadcrumbs?

Before we delve into the technical aspect of how to skip categories in breadcrumbs, it’s essential to understand why this might be necessary. Here are a few reasons why you might consider skipping certain categories:

  • Relevancy: Sometimes, including all parent categories in the breadcrumb trail can dilute the relevancy of the breadcrumbs, especially if the skipped category is not directly related to the product or content being viewed.
  • User Experience: Long breadcrumb trails can be overwhelming and might not provide the best user experience, especially on mobile devices or smaller screens.
  • SEO Considerations: Breadcrumb trails are essential for search engines to understand the structure and hierarchy of your site. By skipping certain categories, you can help search engines focus on the most relevant aspects of your site.

Steps to Skip Categories from Breadcrumbs on the Category Page in Magento 2:

Step 1: Create the registration.php file inside the Extension folder.

app\code\Vendor\Extension\

And add the code as follows

Step 2: Now, create module.xml file inside etc folder.

app\code\Vendor\Extension\etc\

Then include the code as mentioned below

Step 3: Then create CustomAttributes.php file inside the Data folder.

app\code\Vendor\Extension\Setup\Patch\Data

And add the following code snippet

Step 4: Then create di.xml file inside frontend folder.

app\code\Vendor\Extension\etc\frontend\

And add the following piece of code

Step 5: After that, create Breadcrumbs.php file inside Block folder.

app\code\Vendor\Extension\Block\

And add the below-mentioned code

Step 6: Lastly, create category_form.xml file inside ui_component folder.

app\code\Vendor\Extension\view\adminhtml\ui_component

And add the code as below

Result:

In Magento 2, by default the Breadcrumbs are shown as follows

Default Breadcrumbs

After implementing the above steps, you can easily skip some categories from breadcrumbs by adding the category ID from Magento admin as shown below

Category ID

Look into the frontend of your Magento 2 store. Those categories will not be visible on the breadcrumbs.

Skip categories from breadcrumbs

Conclusion:

By following these steps, you can create a more relevant and user-friendly breadcrumb trail that enhances the overall browsing experience on your Magento 2 store.

Relevant Article – 

How to Show/Remove Breadcrumbs to CMS Pages in Magento 2

If you have any doubt, share it with me through the comment section.

Happy Coding!

Click to rate this post!
[Total: 0 Average: 0]