{"id":409,"date":"2019-05-08T11:03:52","date_gmt":"2019-05-08T11:03:52","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/2019\/05\/08\/create-child-theme-in-magento-2\/"},"modified":"2025-05-22T16:53:12","modified_gmt":"2025-05-22T11:23:12","slug":"create-child-theme-in-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/create-child-theme-in-magento-2\/","title":{"rendered":"How to Create Child Theme in Magento 2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Themes in Magento 2 defines the look and feel of your store. Having the graphics and appearance details, the parent theme customization is not advisable.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Hence, the theme inheritance!<i> <\/i><br><i>(<strong>Note<\/strong>: There is no limitation for the level of the theme inheritance)<\/i><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you want to customize the appearance, it is sane to create child theme in Magento 2 rather than implementing the changes in the parent theme. Because, if the changes are directly implemented in the parent theme, upgrading the Magento version results in loss of theme changes in the parent theme. Banner displayed in the frontend is not designed keeping in mind any custom theme designs. The solution to this issue is to <a title=\"How to Override Extension File in Theme in Magento 2\" href=\"https:\/\/meetanshi.com\/blog\/override-extension-file-in-theme-in-magento-2\/\">Overriding Extension Files Using Your Magento 2 Theme<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To easily extend the theme and minimize the maintenance tasks, create <i>child theme in Magento 2<\/i> and customize it. By definition, the child theme is a theme that inherits all the properties of the parent theme. It is useful to customize the existing parent theme design as per the requirements.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Steps to Create Child Theme in Magento 2:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before following these steps, note that &#8220;Meetanshi&#8221; is the vendor name and &#8220;luma&#8221; is the parent theme name.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1. Create a child theme folder named as <strong>{parent-theme-name}_child<\/strong> in the following folder path.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Magento root folder\/app\/design\/frontend\/Meetanshi\/luma_child<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Name your child theme related to the parent theme. It can be anything that is developer friendly!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2. Create file <strong>theme.xml<\/strong> inside the child theme to specify the parent theme inherited by the child theme<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;theme xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\n       xsi:noNamespaceSchemaLocation=\"urn:magento:framework:Config\/etc\/theme.xsd\">\n    &lt;title>{Child Theme Name}&lt;\/title>\n    &lt;parent>{parent-theme-vendor-name}\/{parent-theme-name}&lt;\/parent>\n    &lt;media>\n        &lt;preview_image>media\/preview.png&lt;\/preview_image>\n    &lt;\/media>\n&lt;\/theme><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;theme xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\n       xsi:noNamespaceSchemaLocation=\"urn:magento:framework:Config\/etc\/theme.xsd\">\n    &lt;title>Luma Child&lt;\/title>\n    &lt;parent>Magento\/luma&lt;\/parent>\n    &lt;media>\n        &lt;preview_image>media\/preview.png&lt;\/preview_image>\n    &lt;\/media>\n&lt;\/theme><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">3. Create a <strong>registration.php<\/strong> file for registering your child theme.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\\Magento\\Framework\\Component\\ComponentRegistrar::register(\\Magento\\Framework\\Component\\ComponentRegistrar::THEME, \n    'frontend\/{theme-vendor-name}\/{parent-theme-name}_child', \n    __DIR__\n);<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>{theme-vendor-name}<\/strong>&nbsp;should exactly match the vendor folder name. Vendor name should be capitalized. Ex: Meetanshi<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n \\Magento\\Framework\\Component\\ComponentRegistrar::register(\n    \\Magento\\Framework\\Component\\ComponentRegistrar::THEME,\n    'frontend\/Meetanshi\/luma_child',\n    __DIR__\n );<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">4. Create&nbsp;<strong><strong>composer.json<\/strong><\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">{\n    \"name\": \"{theme-vendor-name}\/theme-frontend-{parent-theme-name}-child\",\n    \"description\": \"N\/A\",\n    \"require\": {\n        \"php\": \"~5.5.0|~5.6.0|~7.0.0|~7.1.0|~7.2.0|~7.3.0\",\n        \"{parent-theme-vendor-name}\/{parent-theme-name}\": \"100.0.*\",\n        \"magento\/framework\": \"100.0.*\"\n    },\n    \"type\": \"magento2-theme\",\n    \"version\": \"100.0.1\",\n    \"license\": [\n        \"OSL-3.0\",\n        \"AFL-3.0\"\n    ],\n    \"autoload\": {\n        \"files\": [\n            \"registration.php\"\n        ]\n    }\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">{\n    \"name\": \"meetanshi\/theme-frontend-luma-child\",\n    \"description\": \"N\/A\",\n    \"require\": {\n        \"php\": \"~5.5.0|~5.6.0|~7.0.0|~7.1.0|~7.2.0|~7.3.0\",\n        \"magento\/luma\": \"100.0.*\",\n        \"magento\/framework\": \"100.0.*\"\n    },\n    \"type\": \"magento2-theme\",\n    \"version\": \"100.0.1\",\n    \"license\": [\n        \"OSL-3.0\",\n        \"AFL-3.0\"\n    ],\n    \"autoload\": {\n        \"files\": [\n            \"registration.php\"\n        ]\n    }\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">5. Create web directory inside the child theme with the following empty directories and files. The whole directory structure for the child theme is:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2019\/05\/Magento-2-Create-Child-Theme-File-Path-Meetanshi.png\" alt=\"Magento-2-Create-Child-Theme-File-Path-Meetanshi\" class=\"wp-image-5466\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">6. Provide <strong>access\/permission<\/strong> for child theme directories and files. Go to child theme directory in the terminal and run this command to give permissions for the child theme directory:<strong>&nbsp;chmod -R 777 *Note:<\/strong>&nbsp;If you are working in a local or development server you can provide 777 access for both files and directories. If live server, then you have to give 755 for directory and 644 for files.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">7. The admin panel shows the created child theme.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Login to admin panel<\/li>\n<\/ol>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>Go to <strong>Content &gt; Themes<\/strong><\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2019\/05\/1_theme-1024x287.png\" alt=\"1_theme\" class=\"wp-image-5467\"\/><\/figure>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>Select child theme in admin configuration<\/li>\n<\/ol>\n\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li>Go to<strong> Content &gt; Design &gt; Configuration<\/strong>.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2019\/05\/2_design-configuration.png\" alt=\"2_design configuration\" class=\"wp-image-5468\"\/><\/figure>\n\n\n\n<ol start=\"5\" class=\"wp-block-list\">\n<li>Select the child theme<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2019\/05\/3_select-child-theme-1024x300.png\" alt=\"3_select child theme\" class=\"wp-image-5469\"\/><\/figure>\n\n\n\n<ol start=\"6\" class=\"wp-block-list\">\n<li>Save<\/li>\n<\/ol>\n\n\n\n<ol start=\"7\" class=\"wp-block-list\">\n<li>Flush the cache<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">8. Take a backup of pub\/static folder for images, CSS, and js. Also, delete the static folder and run static content deploy.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">9. Go to the Magento root folder in your terminal and <strong>deploy static content<\/strong> using the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>php bin\/magento setup:static-content:deploy<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">10. The newly created child theme will also deploy in the <strong>pub\/static<\/strong> folder.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That&#8217;s all for creating a Magento 2 child theme! You can now go on with customizing your child theme.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Do rate the post with 5 stars if found useful.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Themes in Magento 2 defines the look and feel of your store. Having the graphics and appearance details, the parent theme customization is not advisable&#8230;.<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-409","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/409","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=409"}],"version-history":[{"count":4,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/409\/revisions"}],"predecessor-version":[{"id":15436,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/409\/revisions\/15436"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=409"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=409"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=409"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}