Uninstall a storefront theme
What’s in this topic
This topic describes how to uninstall a storefront theme in Magento 2.
The way a 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.
- Set your Magento application to the developer or default mode.
- 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 .
- 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 a manually added theme
If you created or manually installed the theme, it does not matter how you installed Magento.
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.
- Remove the theme record from database. If you are using MySQL, run the following command to do this:
mysql -u <user> -p -e "delete from <dbname>.theme where theme_path ='<Vendor>/<theme>' AND area ='frontend' limit 1"
<user>: your Magento database username
<dbname>: your Magento database name
<Vendor>/<theme>: relative path to the theme directory
Uninstall a theme package
The flow for uninstalling a theme that is Composer package is different, depending on the way your Magento instance was installed.
Uninstall a theme package if Magento was installed using Composer
If both the theme and the Magento instance were installed using Composer, you can use a special CLI command. Follow the instructions from the Uninstall themes Composer package topic.
Uninstall a theme package if Magento was installed by cloning the repository
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.jsonfile.
- Find a line with a reference to theme package and delete it. The reference would look like following:
To update the project dependencies, run:
magento theme:uninstallCLI command as described in the Uninstall themes Composer package topic.
You can use the Composer remove command to remove the dependency, but in that case you will also to delete theme record from database manually.
Uninstall a theme extension
If the theme was installed as an extension, you can uninstall it using one of the following flows:
- the same way as theme Composer packages are uninstalled, see the Uninstall a theme package section for details.
- using the Component Manager.
To uninstall a theme extension using the Component Manager:
- In the Magento Admin Panel, navigate to System > Web Setup Wizard > Component Manager.
- In the Actions column, click Select > Uninstall in the theme record. See the following image for illustration.