November 27, 2022

How To Uninstall a Magento Theme: A Detailed Information | Nexcess

5 min read

You may uninstall a Magento 2 theme in two methods:

  • By eradicating it from the Magento codebase and database manually.
  • By utilizing the Magento theme uninstall command.

The strategy you should utilize is determined by a number of elements, akin to:

  • How the Magento 2 software was put in — utilizing Composer or cloning GitHub.
  • How the theme was put in — utilizing Composer or by importing theme recordsdata.

In case you put in the theme by importing the recordsdata, you should uninstall it manually no matter the way you put in Magento. However, when you put in it utilizing Composer, then the removing methodology varies primarily based on the Magento set up course of.

Preserve studying to study:

Stipulations for Uninstalling a Magento 2 Theme

Observe these steps earlier than you take away a theme in Magento 2.

1. Make sure the Theme Isn’t Utilized to a Retailer View

Go to Content material > Design > Configuration within the Magento admin. Make sure the theme you want to uninstall isn’t assigned to a retailer view. Whether it is, comply with Adobe’s information demonstrating tips on how to change a theme in Magento 2 and assign an alternate theme.

2. Confirm the Theme Isn’t Set as a Father or mother Theme

Go to Content material > Design > Themes within the Magento admin panel. Verify the Father or mother Theme column to confirm your customized theme isn’t listed there. Whether it is, uninstall the kid theme first after which the mother or father theme.

3. Again up the Magento Database and Filesystem

Adobe deprecated Magento’s inbuilt backup performance in Magento 2.3.0 and later variations. Though you may nonetheless use it from the command-line interface (CLI), they not advocate utilizing it.

Seek the advice of your internet hosting supplier for choices to again up your Magento retailer and discover another binary backup instrument akin to Percona XtraBackup to backup the database.

In case you’re a Nexcess buyer, you may take an on-demand backup of your Magento retailer along with the free 30-day incremental backups. Log in to your Shopper Portal and go to Plan Dashboard > Backups > Create Backup to again up your retailer.

4. Change the Magento Operation Mode to Developer or Default

Clear generated courses and proxies from the Magento CLI utilizing the next command:


$ rm -rf <magento-root>/generated/metadata/* <magento-root>/generated/code/*


Then, change Magento to the developer mode utilizing:


$ php bin/magento deploy:mode:set developer


Steps To Uninstall a Magento 2 Theme Manually

In case you’re utilizing a customized Magento theme, you might have put in it manually by putting the theme recordsdata in a listing within the app/design folder within the Magento root.

Right here’s how one can manually take away a theme in Magento 2:

Step 1: Allow Upkeep Mode

Put your retailer in upkeep mode to disable bootstrapping once you uninstall the Magento 2 theme.

Log in to your Magento 2 server because the Magento file system proprietor and run the next command to allow upkeep mode:


$ php bin/magento upkeep:allow


Step 2: Take away the Theme Listing From the Magento Filesystem

Manually put in Magento themes are normally positioned within the app/design listing within the Magento root. Discover the trail to the place the theme recordsdata are positioned within the Magento root and delete the theme folder.

For instance:


$ rm -rf <magento-root>/app/design/frontend/<vendor-name>


Step 3: Take away the Theme Report From the Magento Database

Subsequent, to take away the Magento 2 theme, delete all information and references to the theme inside the shop database utilizing the next command:


$ mysql -u <person> -p -e “delete from <dbname>.theme the place theme_path ='<vendor>/<theme>’ AND space =’frontend’ restrict 1”


Change the next placeholders earlier than executing the command:

  • <person>: Enter the Magento database username.
  • <dbname>: Enter the Magento database identify.
  • <vendor>/<theme>: Enter the relative path to the theme listing.

Step 4: Clear Caches and Disable Upkeep Mode

To finish the uninstallation course of, clear all Magento caches utilizing the next command:


$ php bin/magento cache:clear


Lastly, disable upkeep mode utilizing:


$ php bin/magento upkeep:disable


In case you discover any errors on the frontend, clear the cache of different caching purposes akin to Varnish or Redis.

Steps To Uninstall a Magento 2 Theme Utilizing Composer

The steps to uninstall a Magento 2 theme utilizing Composer differ barely primarily based on the Magento 2 set up methodology. In case you put in Magento utilizing Composer, you may uninstall the theme utilizing a CLI command.

Nonetheless, when you put in Magento by cloning its Git repo, you’ll must take away the theme from Magento’s composer.json file earlier than utilizing the command.

Right here’s tips on how to uninstall a Magento 2 theme utilizing Composer:

Step 1: Take away the Theme From the Magento composer.json File (GitHub Set up Solely)

Be aware: This step is simply required when you’ve put in Magento by cloning its Git repository.

Log in to the Magento file system and go to the Magento root listing.

Edit the Magento composer.json file utilizing your most well-liked textual content editor and delete the road referencing the theme package deal.

Right here’s a composer.json file with pattern information for reference:

After eradicating the reference to the theme package deal from the “require” part, replace the Magento mission dependencies through the CLI utilizing:


$ composer replace


Now, you may safely run the Magento theme uninstall command as described within the subsequent step.

Be aware: You too can take away the dependency utilizing the composer take away command. Nonetheless, in that case, be sure you delete the theme report from the Magento database manually.

Step 2: Run the Magento Theme Uninstall Command

Execute the next command within the CLI:


$ php bin/magento theme:uninstall –backup-code –clear-static-content {theme path}


This command:

  • Checks if the theme exists on the outlined theme path.
  • Verifies the theme is a Composer package deal.
  • Checks for dependencies, verifies the absence of a digital theme, and that the theme isn’t at the moment in use.

If all checks are profitable, it’s going to:

  • Put the shop in upkeep mode and again up the codebase if the –backup-code command is used.
  • Take away the theme from the Magento database tables first after which from the codebase with composer take away.
  • Clear cache recordsdata and generated courses. If –clear-static-content is specified, it’s going to additionally clear static view recordsdata.
  • Disable upkeep mode as soon as the method is full.

If dependencies exist, you might even see an error akin to:

Resolve the dependency situation and rerun the uninstall command. If the theme depends on one other theme, you may take away each concurrently as follows:


$ php bin/magento theme:uninstall frontend/SampleCorp/SampleModuleTheme frontend/SampleCorp/SampleModuleThemeDepend –backup-code


Closing Ideas: How To Uninstall a Magento Theme

Irrespective of the way you uninstall a Magento 2 theme, be sure you seek the advice of your theme builders’ documentation for further steps akin to eradicating any related extensions. It additionally helps to take a backup of your Magento retailer to keep away from information loss.

Get entry to on-demand backups on the click on of a button and simplify working a Magento retailer by signing up for Managed Magento internet hosting with Nexcess at the moment.


Leave a Reply

Your email address will not be published.