Cookies setting

Cookies help us enhance your experience on our site by storing information about your preferences and interactions. You can customize your cookie settings by choosing which cookies to allow. Please note that disabling certain cookies might impact the functionality and features of our services, such as personalized content and suggestions. Cookie Policy

Cookie Policy
Essential cookies

These cookies are strictly necessary for the site to work and may not be disabled.

Information
Always enabled
Advertising cookies

Advertising cookies deliver ads relevant to your interests, limit ad frequency, and measure ad effectiveness.

Information
Analytics cookies

Analytics cookies collect information and report website usage statistics without personally identifying individual visitors to Google.

Information
mageplaza.com

Magento 2 Overriding Native Layout File

Vinh Jacker | 03-17-2025

Magento 2 Overriding Native Layout File

The layout can be considered as one of the core components as it represents a webpage design’s structure using an XML file where the user interface control is appropriately displayed. When you want to adjust your webpage with custom extension without messing things up in the Magento Core Files, overriding Native Layout File would be the best option for you in this situation.

In addition, in Magento 2, not all layout customizations can be performed by extending layouts. If the amount of customizations is too large, it’s better to use overriding. Overriding layout means that new files you created in the theme will be used instead of the layout files in the parent theme layout file of the base layout file.

Now let’s go into detailed instruction on how to override a native layout file in Magento 2.

Magento 2 Overriding Native Layout File

In particular, to override Magento base layout file, you will need to create a layout file .xml in the location which is mentioned below.

<theme_dir>
  |__/<Namespace_Module>
    |__/layout
      |__/override
         |__/base
           |--<layout1>.xml
           |--<layout2>.xml

After you have located your file, the following layouts will be overriden by the file: <module_dir>/view/frontend/layout/<layout1>.xml <module_dir>/view/frontend/layout/<layout2>.xml

Magento 2 Override theme layouts

On the other hand, to override theme layouts, you can repeat the above step. However, this time your new layout file has to be located in another location, which is:

<theme_dir>
  |__/<Namespace_Module>
    |__/layout
      |__/override
         |__/theme
            |__/<Parent_Vendor>
               |__/<parent_theme>
                  |--<layout1>.xml
                  |--<layout2>.xml

The following files will be overriden: <parent_theme_dir>/<Namespace>_<Module>/layout/<layout1>.xml <parent_theme_dir>/<Namespace>_<Module>/layout/<layout2>.xml

Please remember that your new layout files need to be named the same as the file’s name that you want to override.

Conclusion

Above I have just provided you the overriding Native Layout File method which allows you to adjust nice touches to your webpage without touching Magento Core Files. Hope it would be helpful for you. If you have any questions or new ideas, feel free to leave a comment below.

x
    Jacker

    Jacker is the Chief Technology Officer (CTO) at Mageplaza, bringing over 10 years of experience in Magento, Shopify, and other eCommerce platforms. With deep technical expertise, he has led numerous successful projects, optimizing and scaling online stores for global brands. Beyond his work in eCommerce development, he is passionate about running and swimming.



    Related Post

    Website Support
    & Maintenance Services

    Make sure your store is not only in good shape but also thriving with a professional team yet at an affordable price.

    Get Started
    mageplaza services