Uninstall themes
Before you use this command, you must know the relative path to your theme. Themes are located in a subdirectory of <magento_root>/app/design/<area name>. You must specify the path to the theme starting with the area, which is either frontend (for storefront themes) or adminhtml (for Admin themes).
For example, the path to the Luma theme provided with Adobe Commerce is frontend/Magento/luma.
For more information about themes, see theme structure.
Overview of uninstalling themes
This section discusses how to uninstall one or more themes, optionally including the themes’ code from the file system. You can create backups first so you can restore the data later.
This command uninstalls only themes that are specified in composer.json; in other words, themes that are provided as Composer packages. If your theme is not a Composer package, you must uninstall it manually by:
-
Updating the
parentnode information intheme.xmlto remove references to the theme. -
Removing theme code from the file system.
Uninstall themes
Command usage:
bin/magento theme:uninstall [--backup-code] [-c|--clear-static-content] {theme path} ... {theme path}
Where
{theme path}is the relative path to the theme, starting with the area name. For example, the path to the Blank theme supplied with Adobe Commerce isfrontend/Magento/blank.--backup-codebacks up the codebase as discussed in the paragraphs that follow.--clear-static-contentcleans generated static view files, which is necessary to cause static view files to display properly.
The command performs the following tasks:
-
Verifies that the specified theme paths exist; if not, the command terminates.
-
Verifies that the theme is a Composer package; if not, the command terminates.
-
Checks for dependencies and terminates the command if there are any unmet dependencies.
To work around this, you can either uninstall all themes at the same time or you can uninstall the depending on theme first.
-
Verifies that the theme is not being used; if it is being used, the command terminates.
-
Verifies that the theme is not the base of the virtual theme; if it is the base of a virtual theme, the command terminates.
-
Puts the store in maintenance mode.
-
If
--backup-codeis specified, back up the codebase, excluding thepub/static,pub/media, andvardirectories.The backup file name is
var/backups/<timestamp>_filesystem.tgzYou can restore backups at any time using the
magento setup:rollbackcommand. -
Removes themes from the
themedatabase table. -
Remove themes from code base using
composer remove. -
Cleans the cache.
-
Cleans generated classes
-
If
--clear-static-contentis specified, cleans generated static view files.
For example, if you attempt to uninstall a theme that another theme depends on, the following message displays:
Cannot uninstall frontend/ExampleCorp/SampleModuleTheme because the following package(s) depend on it:
ExampleCorp/sample-module-theme-depend
One alternative is to uninstall both themes at the same time as follows backing up the codebase:
bin/magento theme:uninstall frontend/ExampleCorp/SampleModuleTheme frontend/ExampleCorp/SampleModuleThemeDepend --backup-code
Messages similar to the following display:
Code backup is starting...
Code backup filename: 1435261098_filesystem_code.tgz (The archive can be uncompressed with 7-Zip on Windows systems)
Code backup path: /var/www/html/magento2/var/backups/1435261098_filesystem_code.tgz
[SUCCESS]: Code backup completed successfully.Removing frontend/ExampleCorp/SampleModuleTheme, frontend/ExampleCorp/SampleModuleThemeDepend from database
Loading composer repositories with package information
Updating dependencies (including require-dev)
Removing frontend/ExampleCorp/SampleModuleTheme, frontend/ExampleCorp/SampleModuleThemeDepend from Magento codebase
- Removing ExampleCorp/sample-module-theme-depend (dev-master)
Removing ExampleCorp/SampleThemeDepend
- Removing ExampleCorp/sample-module-theme (dev-master)
Removing ExampleCorp/SampleTheme
Writing lock file
Generating autoload files
Cache cleared successfully.
Alert: Generated static view files were not cleared. You can clear them using the --clear-static-content option.
Failure to clear static view files might cause display issues in the Admin and storefront.
Disabling maintenance mode
<component root directory>/etc/di.xml.