How to add and apply breadcrumbs.phtml to child theme in Magento 2?

How to add and apply breadcrumbs.phtml to child theme in Magento 2?

August 14, 2026 · Illustrated author avatarBy Stefan Bogdanescu
How to add and apply breadcrumbs.phtml to child theme in Magento 2?

Extending Breadcrumbs HTML in Magento 2 Child Themes

In Magento 2, customizing the breadcrumb layout typically involves creating a new breadcrumbs.phtml file within your child theme’s template directory. This allows you to override the default Magento core template and apply your own styling or logic.

Finding the Default Template

First, let’s clarify where the original breadcrumbs.phtml is located in the Magento 2 codebase:

vendor/magento/module-theme/view/frontend/templates/html/breadcrumbs.phtml

This is the default breadcrumb template file provided by the core theme module. To customize it for your child theme, you need to create a new version of this file and place it within your theme’s directory.

Creating a Child Theme

Assuming you already have a child theme created (if not, follow Magento’s official guide on creating a child theme), navigate to the app/design/frontend/<Vendor>/<Theme> folder of your child theme.

Adding the Custom Template File

Create a new directory structure mimicking the path from the core template file:

app/design/frontend/<Vendor>/<Theme>/Magento_Theme/templates/html/breadcrumbs.phtml

Inside this breadcrumbs.phtml file, you can now add your custom PHP code to modify or extend the default breadcrumb layout. For example, if you want to add additional CSS classes:

<div class="page-title-wrapper<?= $block->getPageClass() ?>">
   <div class="container">
       <?php echo $block->get BreadcrumbsHtml(); ?>
   </div>
</div>

Here, we’ve simply added a new CSS class .page-title-wrapper to the main breadcrumb container.

Registering the New Template in XML

To ensure your custom breadcrumbs.phtml file is used instead of the core one, you need to update your theme’s layout XML. Open your theme’s app/design/frontend/<Vendor>/<Theme>/Magento_Theme/layout/default.xml file and add or modify the following code:

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="breadcrumbs">
            <action method="setTemplate">
                <argument name="template" xsi:type="string">Magento_Theme/html/breadcrumbs.phtml</argument>
            </action>
        </referenceBlock>
    </body>
</page>

This XML instructs Magento to use the custom breadcrumbs.phtml file you created in your theme’s directory.

Clearing Cache and Recompiling

After making these changes, flush your Magento cache using a command like:

php bin/magento cache:flush

Or, if you prefer to recompile and deploy static assets as well:

php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy -f

This ensures that Magento detects your new template file.

Conclusion

Customizing the breadcrumb layout in a Magento 2 child theme involves creating a new breadcrumbs.phtml file and updating the relevant XML configuration. By following this approach, you can easily override the default Magento core template with your own version to apply specific styling or logic required for your site’s design.

Remember to always flush the cache after making changes to ensure your modifications take effect on the frontend. If you encounter any issues, don’t hesitate to explore Laravel Company’s comprehensive resources and guides on Magento 2 theme development.

Magento 2 Extensions Themes

Our network