I want to override sections.phtml file from vendor/magento/module-theme/view/templates/html/

I am using default magento theme

I have created structure,


But it is not running, the default one is getting loaded.


4 Answers 4


You can achieve this two ways, choose either one as per your requirements [from module or theme]

From Theme

Create one custom theme after that you need to create the below file for override sections.phtml


From Module

Create custom module after that create below default.xml file to overwrite sections.phtml


    <?xml version="1.0"?>
     * Copyright © 2013-2017 Magento, Inc. All rights reserved.
     * See COPYING.txt for license details.
    <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
            <referenceBlock name="navigation.sections">
                <action method="setTemplate">
                    <argument name="template" xsi:type="string">YourVendorName_YourModuleName::sections.phtml</argument>

place the sections.phtml in below path



You can do it if You create Your new theme and inherit from base


copy from here


add in your theme /app/design/frontend/Vendor/default/Magento_Theme/templates/html/sections.phtml

  • +1 from me, but if I am not using any theme, I am using default magento 2 theme, then what should be strutcture Commented Apr 6, 2017 at 9:21
  • /app/design/frontend/Magento/default/Magento_Theme/templates/html/sections.phtml Try this ;)
    – Martins
    Commented Apr 6, 2017 at 9:22
  • okay.. let me check that Commented Apr 6, 2017 at 9:22
  • no still not working Commented Apr 6, 2017 at 9:23
  • are You using luma theme ? /app/design/frontend/Magento/luma/Magento_Theme/templates‌​/html/sections.phtml
    – Martins
    Commented Apr 6, 2017 at 9:25

After banging my head for half an hour on this...

The documentation suggests that the templates location should be:


The template we are after being in vendor/magento/module-theme/view/templates/html/ you would think that the path should be


which would correspond to <Namespace> underscore <Module> as per the folder structure, but that's not what the documentation means.

Open the module registration.php and see how it is registered: Magento_Theme so namespace here is Magento and module name is Theme and that's it.

So in the end your path will be:


You have the wrong path in the structure you have to use a theme from default magento like Magento_Blank or create a new theme that has inheritance from a magento theme ( check devdocs on how to create new theme ) and your file has to be in the following structure design/frontend/[Your_Package]/[Your_theme]/Magento_Theme/templates/html/sections.phtml

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.