Build
Normalize naming

Normalize your naming conventions

This is not Drupal specific, but it applies specifically to Drupal due to the freedom that it allows.

Drupal provides label and machine name (e.g. for content types Article and article, Basic Page and page).

Normalizing the way you are name content types, fields, vocabularies, roles, image styles, clean urls... have several benefits:

  • Improve reusability
  • Improve readability
  • Facilitate project onboarding for other collaborators

Here are some rules that can be easily adopted. It should be regarded as a first idea: read the rule then build your own.

Fields

Fields are everywhere: content types, vocabularies, users, blocks, ... so let's start with that.

  • No entity type prefix, field names should remain short and could be used by another entity type (e.g. for a flag, do not use document_status, but status).
  • No plural, following the same rule than SQL tables (btw fields are SQL tables). Multiplicity can change over time (e.g. not field_files but field_file).
  • For entity reference, simply use the machine name of the reference (e.g. document_type).
  • For fields that are specialized by a module (e.g. Telephone or Link), use the name of the module machine name (telephone, link).

Content types

Avoid to be too generic... or too specific.
Being too generic will give a vague idea and could lead to hesitation from the author.
Being too specific will lead to too many content types.

Provide a description for your content type first, the name will come by itself.

Example: Event

Roles

Roles should be defined from the use case of the website. Having personas will help here.

A community of authoring users could be defined by

  • Editor: person that can review and publish content
  • Author: person that can write content and send it to the editor

A real estate website could be defined by

  • Promoter: project manager of a building that can edit properties content.
  • Agency: sales representative that can edit sales status for properties.

This section needs to be completed

  • Image styles
  • Clean URLs
  • File directories from File or Image fields.