Node
A node is one content item in Drupal, such as a page or article, stored as an entity with a title, author, published status and a URL like /node/1.
A node is Drupal's name for a content item: one page, article or other main piece of content, stored as an entity of the type node. Each node has a title, an author, a published status and a numeric ID. It belongs to one content type and is reachable at /node/ followed by its ID; a URL alias can give it a friendlier address.
How nodes work in Drupal 11
The Drupal user guide uses the term content item for it and defines that as an item of content typically displayed as the main content of a page. In code the class is Drupal\node\Entity\Node. It extends EditorialContentEntityBase and implements NodeInterface. The entity type is a content entity with the ID node, and its bundles are content types.
The entity keys map generic roles to node properties: nid is the ID, vid the revision ID, type the bundle, title the label, plus uuid, langcode, status for published and uid for the owner. Core stores nodes in the tables node, node_field_data, node_revision and node_field_revision. The entity type is translatable and revisionable, and it shows a revision user interface.
The node class adds base fields to those keys: a required title of up to 255 characters, Authored by, Authored on, Changed, Promoted to front page and Sticky at top of lists. Everything else, such as a body or an image, comes from fields that administrators add to the content type.
Link templates give each node its addresses, among them /node/{node}, /node/{node}/edit, /node/{node}/delete and /node/{node}/revisions.
Example
In the user guide, an editor chooses Manage › Content › Add content › Basic page, fills in the title and body, checks Published and saves. Drupal creates one node. A developer can do the same in code through the entity type manager, following the pattern in the Drupal.org entity documentation:
$node = $entityTypeManager->getStorage('node')
->create(['type' => 'article', 'title' => 'Sample title']);
$node->save();
The node is stored only when save() runs. To read one back, call load(1) on the same storage.
Common mistakes
- Confusing the node ID with the revision ID. The ID (
nid) identifies the item;vididentifies one saved version of it. - Hard-coding
/node/1in code. The entity API offerstoUrl()to build the address, so the code does not depend on how the path looks. - Treating every entity as a node. Users, taxonomy terms, comments and files are separate entity types.
- Creating a node without a type. The
typevalue in the create call selects the content type, and with it the fields.
For marketing and content teams
When a developer asks for "the node ID" of a page, open its edit form and read the number in /node/{node}/edit. Promoted to front page and Sticky at top of lists are two further settings stored on every node. Whether an item is visible to visitors is set by the Published checkbox.
With DXPR
DXPR Builder is a display format you can choose for a text field of a node, on the Manage display page of its content type. Editors then build the layout on the page itself, not in the edit form. See DXPR Builder.