Table of Contents
Introduction
In this article, we will discuss the process of uninstalling a storefrontΒ themeΒ in Magento 2.
The way theme should be uninstalled is defined by two factors:
-
- The way the theme was added: manually added (installed or created)
- Installed as composerΒ package or as anΒ extension.
- The way Magento was installed: using the source files from GitHubΒ orΒ using Composer.
The following sections describe the flow for uninstalling themes in each case.
Prerequisites
There are following prerequisites :-
If you are performing this process on the production or staging site please take backup. Then start.
1. Set your Magento application to the developer or default mode.
To check the current mode:Β php bin/magento deploy:mode:show
If mode is production then change it by using below command.
php bin/magento deploy:mode:set default
2. Theme should not be applied on the storefront
Make sure that the theme is not applied on the storefront. To do this, in the Admin panel navigate to ContentΒ > Design >Β ConfigurationΒ and make sure that your custom theme is not applied for anyΒ store view.
3. Theme is not defined as a parent for any registered theme
Make sure that the theme is not defined as a parent for any registered theme.
To do this, in the Admin panel, navigate toΒ ContentΒ > Design >Β Themes.
Make sure that your theme is not mentioned in theΒ Parent ThemeΒ column. If it is mentioned, you need to uninstall the child theme first.
Uninstall the Manually Installed Theme
In case if your theme was created or installed manually, the uninstall procedure is the same, regardless the way Magento was installed.
To uninstall a manually added theme:
-
- Navigate to the vendor directory where the theme was installed. This directory should be:Β
<Magento root dir>/app/design/frontend/<VendorName>
. - Remove the theme directory.
- Delete all the content of folderΒ
var/view_preprocessed
Β &Βpub/static/frontend
. - Go to your theme table and delete the entry of the theme which you want to uninstall.
- Run below command:-
- Navigate to the vendor directory where the theme was installed. This directory should be:Β
php bin/magento setup:upgrade && php bin/magento setup:static-content:deploy -f && php bin/magento c:f
Solved – Unable to Load Theme by Specified Key Error in Magento 2
Uninstall Theme with Composer package
The flow for uninstalling a theme that isΒ Composer packageΒ is different, depending on the way your Magento instance was installed.
To uninstall a theme Composer package if your Magento instance was installed by cloning the Git repository, you can also uninstall it using a CLI command. However, you must first remove it from the list of dependencies.
Take the following steps:
- Open theΒ
<Magento root dir>/composer.json
Β file. - Find a line with a reference to theme package and delete it. The reference would look like following:
"require": { ... "<vendor>/<theme-name>": "<version>" },
- To update the project dependencies, run:
composer update
-
php bin/magento setup:static-content:deploy -f && php bin/magento c:f
- Go to your theme table and delete the entry of the theme which you want to uninstall.
Conclusion
In this article, we have learned the steps for uninstalling theme which was installed manually and also with the composer package.
Please feel free to comment below for the feedback and any help. Happy Learning !!