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? – Shawn Abramson Jan 8 '18 at 4:54

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.

| improve this answer | |
  • what is theme_dir and vendor_theme in this case – eulercode Jan 8 '18 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> – Salma Saiyad Jan 8 '18 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 Jan 8 '18 at 6:29
  • Yes. Please add same as defined – Salma Saiyad Jan 8 '18 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

| improve this answer | |

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

| improve this answer | |
  • what is theme_dir, namespace_module, parent_vendor and parent_theme in this case? – eulercode Jan 8 '18 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

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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