Magento: Link to product tabs

Magento: Link to product tabs

October 12, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento: Link to product tabs

Linking Directly to Product Tabs in Magento

If you’re working with a Magento e-commerce site that uses tabs on product pages, you might find yourself wanting to link directly to specific tab sections from your category or other pages. While the basic approach of using anchor tags (<a href="#tab-section">) works for scrolling to a section, it doesn’t automatically open the linked tab.

In this post, we’ll walk through how to achieve this functionality specifically with the Ultimo theme in Magento 2. The solution involves including some custom JavaScript on your category pages and utilizing the built-in Magento tab functions.

Understanding the Problem

The challenge lies in Magento’s default behavior, where clicking a tab triggers an AJAX request for the tab content. Simply linking to an anchor won’t initiate this request and open the tab automatically.

The Solution: Custom JavaScript

To solve this, we need to manually trigger the tab click event using JavaScript when navigating directly via URL with an anchor. Here’s how you can do it:

  1. Create a new Magento 2 theme if you don’t have one already, or modify your existing theme.

  2. In the app/design/frontend/[Vendor]/[Theme]/template/catalog/product/view directory, find or create a file named product/view/tabs.phtml.

  3. Open this file and add the following JavaScript code at the beginning of the <script> block:

<script type="text/javascript">
    require(['jquery', 'mage/tab'], function ($) {
        $(document).ready(function () {
            var hash = window.location.hash;
            if (hash && hash.startsWith('#tab-')) {
                setTimeout(function() {
                    $('a[href="' + hash + '"]').trigger('click');
                }, 50);
            }
        });
    });
</script>

This code uses the jquery and mage/tab libraries to check for a tab-related anchor in the URL. If it exists, it triggers a click event on the corresponding tab link after a slight delay.

Including the Script

To include this script on your category pages:

  1. Go to Content > Pages > [Your Category Page] > Design.
  2. Under the “Layout XML Update XML” field, add or modify the following line inside <referenceContainer name="content">:
<action method="addJs">
    <name>js/require.js</name>
</action>

This ensures that the jquery and mage/tab libraries are loaded on your category pages.

  1. Save the changes, and clear your cache using the command bin/magento cache:clean.

Conclusion

By following these steps, you should now be able to link directly from your category or other pages to specific tabs on your product pages, with the tab automatically opening upon navigation.

Remember that this solution is theme-specific and will work for Magento 2. If you’re using a different theme or version of Magento, the implementation details may vary slightly.

For more advanced customization options and best practices in Magento development, be sure to check out our comprehensive guides on Laravel Company’s blog.

Magento 2 Catalog Database Themes

Our network