HOW DO YOU INSTALL OR UNINSTALL A MAGENTO THEME?

Do you want to install a new Magento theme on your store? We will discuss everything you need to know about installing a third-party theme on your Magento website. Generally, it requires you to add the theme code in the Magento code directory and then registering the theme into the database.  However, you can successfully accomplish installing a theme in Magento by two methods depending upon your file distribution. Themes in Magento come in two different file distributions either as a set of files such as an archive or as a composer package.  Let us discuss in further detail how we can install both of these theme distributions?

Manual Installation of a Magento Theme

Installing a theme is mainly a two-step process as follows:

Step 1: Determining the directory structure of the theme you want to install. The directory should be in this format <vendorName>/<theme>. Also, all of your theme files must be in the <theme> directory.

Step 2: Subsequently, copy this directory into the <magento root>/app/design/frontend directory.

That’s it you have successfully installed your theme manually. Since this theme is locally in your project source code you can edit it directly.

Installing Theme as a Composer Package

As we discussed sometimes your theme can come as a composer package. So, you must use composer to install, manage, and upgrade this theme. Unlike local theme, composer themes are stored in the <vendor> directory.

You can run the following command to install custom theme via composer

composer require scommerce/custom-theme

Since composer installed themes are from an external source, you are not allowed to modify them directly whereas themes created in app/design/frontend can easily be modified.

How do you configure your Theme?

Finally, you will have to configure your installed theme. To accomplish that simply reload or open the admin page of your store. After that, your theme will be added to the database and the registration is complete. To ensure that your theme registered successfully navigate to Content>Design>themes in the admin panel. If your theme is available on the list that means it is registered.

Uninstalling a Magento Theme

Uninstalling a theme depends upon two major factors. First, how did you install the theme in the first place? Whether you added it manually or by using composer package. And the second is how did you install Magento itself? whether by using GitHub repository or composer.  To start the process switch your application to default or developer mode. Ensure that the theme you want to delete is not currently applied in the store. you can easily check it by navigating to Content>Design>themes. Also check, your theme should not be a parent for any other registered theme.  Next, we will discuss the uninstallation process for manual themes and composer themes. 

Manual Themes

Follow the steps below to uninstall a manually added theme:

  • Navigate to the directory of the theme you want to uninstall. The directory will be as <magento root>/app/design/frontend <vendor>.
  • Delete or remove the directory of the theme.
  • Lastly, Remove the database entry for the theme.
delete from theme where theme_path ='<Vendor>/<theme>' AND area ='frontend' limit 1

Composer Themes

If you have installed  your Magento using repositories and theme using composer package then follow the commands below to uninstall:

  • Navigate to the composer JSON file. it should be in directory <magento root>/composer.json.
  • You will have to delete the line referencing your theme package.
  • Lastly, run the composer update command uninstall command to complete the process.
     $ composer install 
     $ 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 frontend/Scommere/CustomTheme.
    –backup-code backs up the Magento 2 codebase as discussed in the paragraphs that follow.
    –clear-static-content cleans generated static view files, which is necessary to cause static view files to display properly.

    We have covered methods to install a third-party theme in your store. Please be aware that this article does not cover installing a theme as an extension. You can learn more about creating your own custom theme in Magento HERE

Similar Posts