Suppose that I want to edit the file


Do I edit the file directly?

It seems not a best practice to me.

Or is there anyway I can extend the file to override the content.

  • There are several ways to do this. Is your intention to build a custom module which will contain your override or is this part of a theme you are building? Commented Jan 8, 2018 at 4:54

4 Answers 4


You can use the following to override the layout file. For Example, vendor/magento/module-theme/view/frontend/layout/default.xml


So you just need to override a file under your theme folder.

  • what is theme_dir and vendor_theme in this case
    – eulercode
    Commented Jan 8, 2018 at 6:15
  • If you see in app/design/frontend/Magento/Luma - This one is default theme where as if you have any theme installed at that time path will be app/design/frontend/<theme_dir>/<vendor_theme> Commented Jan 8, 2018 at 6:24
  • I have only app/design/frontend/Magento and there is no additional folder or file inside it. So i add Luma/Magento_Theme/view/frontend/layout/default.xml inside it am i right?
    – eulercode
    Commented Jan 8, 2018 at 6:29
  • Yes. Please add same as defined Commented Jan 8, 2018 at 7:21

You can do the following things. Create new theme and override this layout in theme. Check luma theme, how to override any xml. And do the same. Check official documentation


To add an overriding theme file (to override a parent theme layout):


Reference: http://devdocs.magento.com/guides/v2.2/frontend-dev-guide/layouts/layout-override.html

  • what is theme_dir, namespace_module, parent_vendor and parent_theme in this case?
    – eulercode
    Commented Jan 8, 2018 at 6:12

Firstly you must create a local theme, for do that you have to create the blow structure


In this folder you create 2 files




<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
    <title>Vendor Theme</title>

And finaly you have to create a below structure


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.