Magento 2 product pages come with a few default tabs — Details, More Information, Reviews — but sooner or later you'll want your own: care instructions, a size guide, warranty terms, spec sheets. In this guide we'll add a custom tab to the product page, driven by a product attribute so every product can have its own content in that tab.
Prefer not to touch code? The Product Tabs Extension for Magento 2 by MageAnts lets you add and manage custom product tabs entirely from the admin. If you'd rather build it yourself, here's the manual method.
Steps to Add a Custom Tab to the Product Page in Magento 2
Step 1: Add a New Attribute for the Custom Tab
The tab's content will come from a product attribute. In the admin, go to Stores → Attributes → Product.
Click Add New Attribute.
Fill in the necessary information:
- Default label: a readable name for the attribute (e.g., Custom Tab).
- Attribute Code: a unique code (e.g., add_custom_tab) — you'll reference this in the template later.
- Catalog Input Type: choose Text Area (or Text Editor) so you can enter rich tab content.
- Scope: choose the appropriate scope for your store setup.
After saving, the attribute (add_custom_tab) appears in the list:
Step 2: Add the Attribute to an Attribute Set
Go to Stores → Attributes → Attribute Set.
Click Add Attribute Set if you don't already have one to use.
Enter Custom Tab as the Attribute Set Name.
Open the Custom Tab attribute set you just created.
Drag and drop the new add_custom_tab attribute from the Unassigned Attributes column into a group, then save.
Step 3: Set the Tab Content on a Product
Open a product in Catalog → Products. Set its Attribute Set to Custom Tab, fill in the Custom Tab field with the content you want to display, and click Save.
Step 4: Create the Module
The layout and template below live in a module — we'll use Mageants_ProductTabs. Create app/code/Mageants/ProductTabs/registration.php:
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Mageants_ProductTabs',
__DIR__
);
|
And app/code/Mageants/ProductTabs/etc/module.xml:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Mageants_ProductTabs" setup_version="1.0.0">
<sequence>
<module name="Magento_Catalog"/>
</sequence>
</module>
</config>
|
Step 5: Create the Layout File
In app/code/Mageants/ProductTabs/view/frontend/layout, create catalog_product_view.xml. This adds a new block into the product details tabs:
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="product.info.details">
<block class="Magento\Catalog\Block\Product\View"
name="custom.tab"
template="Mageants_ProductTabs::custom_tab.phtml">
<arguments>
<argument translate="true" name="title" xsi:type="string">Custom Tab</argument>
</arguments>
</block>
</referenceBlock>
</body>
</page>
|
Step 6: Create the Template File
Create app/code/Mageants/ProductTabs/view/frontend/templates/custom_tab.phtml. Note the correct -> object operator and the escaped output:
<?php
/** @var \Magento\Catalog\Block\Product\View $block */
$product = $block->getProduct();
$customTab = $product->getData('add_custom_tab');
?>
<?php if ($customTab) : ?>
<div class="custom-tab-content">
<?= $block->escapeHtml($customTab) ?>
</div>
<?php endif; ?>
|
Step 7: Enable the Module and View the Result
php bin/magento module:enable Mageants_ProductTabs php bin/magento setup:upgrade php bin/magento setup:static-content:deploy -f php bin/magento cache:flush |
Open the product page and you'll see the new Custom Tab with your content:
Using the Tab for Downloadable Documents
A very common reason to add a custom tab is to hold downloadable files — spec sheets, user manuals, warranty PDFs, size charts. The attribute method above works for text, but it wasn't built for managing file uploads per product. If that's your goal, the Product Attachments extension is purpose-built for it: upload files against any product and they appear in a dedicated attachments tab on the product page, with control over file types, customer-group visibility, and per-store display — no attribute or template work needed.
Conclusion
Adding a custom tab in Magento 2 comes down to an attribute for the content and a small module (layout + template) to render it in the product details section — with two things the original approach missed: use the -> operator, not a lookalike arrow character, and escape your output. For text tabs the DIY route is fine; for admin-managed tabs or downloadable documents, the Product Tabs and Product Attachments extensions save you the maintenance. Questions or suggestions? Get in touch or leave a comment.