
Modules
As we discussed in Chapter 1, Introduction, Drupal is highly modular in its design; you can switch on or off various bits of functionality by enabling/disabling modules, and you can also extend the system by adding new ones.
Other systems may describe modules as plugins—the two are synonymous.
Core and contrib modules
The term Drupal core refers to the set of modules that are present in the main Drupal download that you have just installed. You can achieve a great deal using just these, but developers around the world have created their own modules for specific areas of functionality, which you can also use free of charge.
Collectively, these community-contributed modules are referred to as contrib modules.
All modules can be downloaded from the Drupal website (https://www.drupal.org), and each one has its own individual project page. The project page for each module contains the downloadable code, releases, documentation, and links to the issue queue that we will discuss later in this chapter.
Where the core modules live
In Drupal 8, the core modules are located in the /core/modules
folder.
Tip
Prior to Drupal 8, core modules were located in the /modules
folder.
Where your extension modules should live
You should never put your own modules or any contributed modules in the core
folder.
It is recommended that you place your downloaded and custom module extensions in the /modules
folder located in the Drupal root.
Following this rule will allow you to apply upgrades to the Drupal core system.
Tip
The /sites/all/modules
structure, which was recommended in previous versions of Drupal, is still supported, but should not be used by default.
You can structure your modules folder however you like, but the standard convention is to have a structure in which you clearly segregate community (contrib) modules from any custom modules that you may have written yourself.
Thus, from the top level, the module folder structure is:

An example community module
As an example, let's look at a typical community module, in this case, the Google Analytics module. The Google Analytics module enables you to track visitors to your site using the popular Google Analytics service and can be found at:
https://www.drupal.org/project/google_analytics
The project page will contain a description of the module and one or more links to download it. Modules may be available to support multiple versions of Drupal. You should be downloading modules marked as version 8.x.
The following screenshot shows a typical module project page, in this case, the Google Analytics module:

Evaluating new modules
You should try to evaluate modules from the perspective of the requirements of the site you are building before you go ahead and download them. There are thousands of modules out there in the community; some are great, some are good, and some don't have a lot of traction, so be sure to choose the ones that are right for your use case.
Before you start downloading modules, first consider the following:
- How many downloads does the module have?
The more popular a module is, the more the code will have been analyzed and bugs reported.
- How many installs does the module have?
This is only a guideline as not all sites report back their usage.
- Who is the maintainer?
Some maintainers have many modules which they look after. Maintainer reputation is also an indicator of quality: Is the module in active development? How responsive is the maintainer to the issue queue? When was the most recently committed update? and so on.
- Open bugs and issues?
Every module has its own issue queue (discussed in duplicates or support requests.
Documentation
Some modules have it, while some rely on a README
file. You can see all of this information in the bar on the right-hand side of the module page.
Module versions
Some modules will have a -dev
version listed. This is the most up-to-date code, but may be unstable. Running a -dev
module on a production site is not recommended; although pragmatically speaking, since Drupal 8 has only recently been released, it may well be something that you are forced to do. Most modules will have a recommended version that is currently supported by the maintainer. If in doubt, always use the recommended version.
