Installing Drupal 8 modules
Install one or more modules to modify, extend, or enhance Drupal with additional functionality.
Prerequisites
Step 1: Get the Module
If the module you want to install is part of Drupal core, you can skip to the next step.
To install a contributed module, you first need to obtain its code. The recommended way to add a dependency to your project is by using Composer. This assumes that you are already managing your project with Composer.
To add a module, first identify its short name. This is the last part of the URL of the project page. For example, the Geofield module at https://www.drupal.org/project/geofield has the short name "geofield".
To download the contributed module along with its dependencies, enter the following command in your site’s root directory (replacing the module short name with geofield):
composer require drupal/geofield
After the command completes, you should see confirmation that the module has been added to your project’s composer.json as a dependency and that the code was downloaded.
For more information and video demonstrations, see: Using Composer to Download and Update Files and Downloading Modules and Themes Using Composer.
Alternative methods for getting a module include:
Step 2: Enable the Module
Using the Drupal UI:
- Go to the “Extend” page (admin/modules) through the “Manage” menu.
- Find the module(s) you want to enable and check the box next to each one.
- Click Install to enable the selected module(s).
Using Drush:
drush en geofield
For more information and video demos, see: Downloading and Installing a Module from Drupal.org and Installing Modules from the Command Line.
Additional Information
Module Storage is Organized
Drupal looks for modules in several locations: the root /modules
directory (preferred) or /sites/*/modules
. Within those directories, it searches all subdirectories for modules.
A common convention is to place all modules downloaded from Drupal.org in /modules/contrib
, and all modules with custom project-specific code in /modules/custom
.
Multiple Modules in One Project
Typically, one project (e.g., https://drupal.org/project/devel) includes multiple modules. Each module in the project is listed individually on the Extend page and can be enabled separately.
More Resources
Drupal’s online documentation is © 2000-2020 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.