Magento 2 theme changes are not showing?

Let me just start by saying that you should ALWAYS use a child theme when you are doing customizations rather than implementing all changes in the parent theme. The reason for that is to avoid losing those customization whenever you upgrade your theme.

Having said that sometimes you find that the custom changes you made on that child theme are not showing on the frontend. Why is that? What is happening?

Here is a list to help you troubleshoot the problem:

Make sure your magento 2 child theme is set correctly

To create a child theme you must create the correct folder hierarchy and have all mandatory files.
A child theme, as any other theme, has a root folder, usually the Vendor name, and inside a theme folder, usually the theme name. This VendorName/ThemeName hierarchy need to be inside the app/design/frontend folder. So your final folder hierarchy will be

app/design/frontend/VendorName/ThemeName

Inside this folder is where all you files should reside. The ones that are mandatory to set up a theme are:

  • registration.php
  • theme.xml

The registration.php file is responsible to register the theme in magento. It will look something like this:

<?php
/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */

\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::THEME,
    'frontend/VendorName/ThemeName',
    __DIR__
);

The theme.xml file describes to magento some attributes of the theme that you are creating, namely, and most importantly, the parent theme set under the parent element. The simplest theme.xml file will be similar to this:

<!--
/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
    <title>Theme Name</title>
	<parent>ParentVendorName/ParentThemeName</parent>

</theme>

When you clear your cache you will see that the theme will be registered and it will show in the backend under Content > Design > Themes

Check if your theme is NOT virtual

Internally, the registration process creates a new entry on the Theme table in the database like is showing below

Notice that there is a type column with value 0 for our child theme, meaning that this is a physical (visible) theme. If this value is 1 (virtual) then your theme will NOT be taken into account when rendering your pages. If this is happening change that value to 0.

Check if you have not another theme scheduled

This is probably the most obvious and, for that, the most unlikely to be checked when you are troubleshooting this problem.

Go to Content > Design > Schedule and make sure no other theme is set to be used! This happened to me once and I literally lost hours debugging before noticing that someone working before me set up the main theme in the schedule table!

Well, lesson learned… Now I always check it 🙂

Check if the page you are viewing is not set to use another theme

Finally confirm that the page you are viewing is not configured to use a specific theme in the admin or even in the code. The theme can be set per page in magento 2, overriding the default site’s theme. So, you need to check in the admin and ultimately in the site’s code.

Start with the admin and go to the page editing and look for the design tab. Confirm that it is not set to use another theme. Checking the code will be harder and you will need to look into the xml layout files that are used to build that page.

Leave a Reply

Your email address will not be published. Required fields are marked *