Custom module
A module written for one site only and kept in that project's own code, next to the site's core and contributed modules.
A custom module is a Drupal module that you write for your own site instead of downloading it. The Drupal User Guide separates it from core modules, which ship with Drupal, and contributed modules, which come from Drupal.org. Your team owns its code.
How custom modules work in Drupal 11
Technically nothing separates a custom module from other modules. It is a folder with a MODULE.info.yml file, found by Drupal in the /modules directory or a /sites/*/modules directory. You install it like any other module, on the Extend page or with Drush.
The machine name is the identity of the module. Code and file names inside the module use it, for example my_module.info.yml.
In the info file, name, type and core_version_requirement are required; the Drupal 11.4 info parser throws an exception when a module outside core lacks the last one. That key takes a Composer-style constraint, so one module can declare support for several major versions, for example ^10 || ^11.
What goes into the module depends on the job. The Drupal.org Hello World tutorial walks through a routing file, a controller, a menu link and default configuration. Other typical parts are hooks, and services that receive what they need through dependency injection.
Example
This is a complete minimal module. Save it as modules/custom/my_module/my_module.info.yml:
name: My module
type: module
description: 'Small site-specific additions.'
package: Custom
core_version_requirement: ^11
It appears on the Extend page under the group named in package, and it can be installed with drush pm:install my_module.
Common mistakes
- Naming the module like an existing project. A clash with a contributed module, a theme or a profile breaks the uniqueness rule.
- Breaking the naming rules. The name starts with a letter and has no spaces or uppercase letters. Drupal.org lists a limit of 50 characters and reserved words such as
src,libandvendor. - Declaring too narrow a core constraint. Drupal compares the constraint with the running core version, so a module that lists only
^10is flagged as incompatible on Drupal 11.
For marketing and content teams
A custom module is the right answer when a requirement is specific to your site, such as a special import or a connection to an internal system. It is also a commitment: nobody outside your team updates it. Ask a developer who will maintain it, where its code lives in the repository, and whether a contributed module already covers the need. Ask for it to be documented and kept in version control, so another developer can take it over.