This recipe will cover the steps required to install and enable a downloaded theme.
Downloaded themes are made available in both the ubiquitous zip format as well as the format which usually offers superior compression. These files can be extracted using archive programs such as 7-Zip (http://www.7-zip.org) as well as commercial packages such as WinZip (http://www.winzip.com) and WinRAR (http://www.rarlabs.com).
To install a theme, open Windows Explorer and navigate to the Drupal installation:
1. Browse to
sites/all/themes
.2. Extract the downloaded theme into a subfolder inside this folder. In other words, if the theme is called
mytheme
, the foldersites/all/themes/mytheme
should contain all the files of the theme:
In the previous screenshot, we see the Sky theme’s installation folder situated within sites/all/themes
. Themes also often contain a README.txt file which provides documentation which is worth a read-through.
Note
File structure options
In this recipe, we have chosen to use the folder sites/all/themes/
to store our theme. By positioning our theme inside sites/all
, we are stating that the theme is to be available to all sites using this Drupal installation. In other words, this enables multi-site setups to share modules and themes. In case we want to restrict access to the theme solely to one particular site, we would position its folder within sites/foo.example.com/themes/
where foo.example.com
is the site in question.
3. Access the Drupal site in a browser and navigate to
admin/appearance
[Home | Administration | Appearance].4. As in the following screenshot, the newly installed theme should now be listed on this page under the Disabled themes section. Click on the associated Enable and set default link to activate the theme:
Drupal scans folders within sites/all/themes
and in particular looks for files with the extension .info
. These files contain information about each theme such as its name, description, version compatibility, and so on. If the theme is compatible, it is listed on the theme administration page.
A site can have multiple themes enabled. Out of these, only one can be chosen as the default theme. The default theme is, as the name suggests, the primary theme for the website. In the following screenshot, we can see that the Sky theme is now enabled and is the new default theme for the site overriding the core theme, Bartik, which is relegated to second position in the list of enabled themes:
Drupal makes it easier for us to manage our sites by following preset naming conventions when it comes to the folder structure of the site.
Themes do not necessarily have to be placed at the root of the sites/all/themes
folder. For organizational purposes, it might be useful to create sites/all/themes/contrib
and sites/all/themes/custom
. This will allow us to differentiate between downloaded themes and custom themes.
Note
Since Drupal’s core themes are located within the root themes
folder, we might be led to believe that this could be a good place to store our contributed or custom themes. While this will certainly work, it will prove to be a bad decision in the long run as it is never a good idea to mix core files with custom files. The chief reason for this separation is manageability. It is far easier to maintain and update Drupal when there is a clear distinction between the core installation and contributed or custom modules and themes. It also ensures that we do not accidentally overwrite or lose our changes when we upgrade our site to the next Drupal release.
Enabled themes can be disabled by clicking on their associated Disable links. However, this can only be done if they are not currently the default theme of the site. If the link is missing, then another theme will first need to be set as the default. Once this is done, the Disable link should automatically become available.
Once a theme is enabled, the next logical step would be to configure it. The following recipes in this chapter, namely Uploading a new logo, Uploading a new favicon, and so on describe how to do so.
While this recipe dealt with installing and enabling a downloaded theme, it is also a good idea to consider Creating a subtheme based on a core theme recipe in Chapter 2, Beyond the Basics as well as Creating a theme from scratch recipe in Chapter 3, Custom Themes and Zen.