Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Usage Milestone: Google Analytics Module google_analytics crossed 1,000 active installs. Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Release: GraphQL Compose Codegen 1.1.2 Minor update available for module graphql_compose_codegen (1.1.2). Release: Mapy.com 1.1.3 Minor update available for module mapycom (1.1.3). Release: Ckeditor5 entity browser 3.0.3 Minor update available for module ckeditor5_entity_browser (3.0.3). Release: Ckeditor5 entity browser 3.0.1 Minor update available for module ckeditor5_entity_browser (3.0.1). Release: Ckeditor5 entity browser 3.0.2 Minor update available for module ckeditor5_entity_browser (3.0.2). Release: Teamleader Integration 4.0.2 Minor update available for module teamleader (4.0.2). Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

Site Configuration

11 sites Security covered Drupal 10–11
View on drupal.org

This module offers a centralized system to define, manage, and access global site configurations. It automatically generates an administration interface for these configurations and can expose them through optional REST or JSON:API endpoints, making it suitable for decoupled Drupal sites.

Provides a centralized way to define, manage, and expose global site configuration in Drupal, with first-class support for decoupled or headless architectures.

This module allows developers to define structured configuration groups via plugins, automatically generates an administration UI, and exposes the stored values through services and optional API endpoints (REST and JSON:API).

Features

SiteConfig plugin type

This module introduces a new plugin type called SiteConfig, which allows you to define logical groups of configuration fields using annotations.

Each plugin represents a configuration set with:

  • A unique ID
  • A label and description
  • A list of fields with type, label, options, and validation
  • Optional storage and translation settings

Plugins must be created under:

src/Plugin/SiteConfig

Example SiteConfig plugin

Define the Plugin using PHP Attributes (Recommended)

namespace Drupal\your_module\Plugin\SiteConfig;

use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\site_config\Attribute\SiteConfig;
use Drupal\site_config\SiteConfigPluginBase;

#[SiteConfig(
  id: "custom_settings_attribute",
  label: new TranslatableMarkup("Custom Settings attribute"),
  fields: [
    "welcome_message" => [
      "type" => "textfield",
      "title" => "Welcome Message",
      "description" => "A message shown on the home page.",
    ],
    "featured_node" => [
      "type" => "entity_autocomplete",
      "target_type" => "node",
      "title" => "Featured Content",
    ],
  ],
  storage: "config",
  translatable: true,
)]
class YourPluginName extends SiteConfigPluginBase {
}
Define the Plugin using Annotations (Legacy)
namespace Drupal\site_config\Plugin\SiteConfig;

use Drupal\site_config\SiteConfigPluginBase;

/**
 * Plugin implementation of a SiteConfig.
 *
 * @SiteConfig(
 *   id = "foo",
 *   label = @Translation("Foo"),
 *   description = @Translation("Foo description."),
 *   fields = {
 *     "field_1" = {
 *       "label" = @Translation("Field 1"),
 *       "type" = "select",
 *       "options" = { 0 = "No", 1 = "Yes" },
 *       "required" = TRUE
 *     },
 *     "field_2" = {
 *       "label" = @Translation("Field 2")
 *     }
 *   },
 *   storage = "config",
 *   translatable = TRUE
 * )
 */
class Foo extends SiteConfigPluginBase {
}

Plugin options

  • storage (optional): determines where the values are stored.
    Possible values: state, config.
    Default: state
  • translatable (optional): enables translation support for configuration values.
    Default: FALSE
  • field type (optional): defaults to textfield if not specified.

Automatically generated admin form

The module provides an administration page at:

/admin/site-config

This form is generated automatically based on the defined SiteConfig plugins and handles storing and retrieving their values.


API submodules

The module includes two optional submodules to expose configuration values for decoupled frontends.

site_config_jsonapi

Provides JSON:API endpoints:

  • Get all site configs: /jsonapi/site-config
  • Get a specific config by ID: /jsonapi/site-config/item/{id}

site_config_rest

Provides REST endpoints:

  • Get all site configs: /api/site-config
  • Get a specific config by ID: /api/site-config/{id}

Services

The module defines the SiteConfigService, which allows programmatic access to configuration values:

 \Drupal::service('site_config.service')->getSiteConfig(); 

Returns all configuration values.

 \Drupal::service('site_config.service')->getSiteConfigById('foo'); 

Returns all values for a specific SiteConfig plugin.

 \Drupal::service('site_config.service')->getValue('foo', 'field_1'); 

Returns a single field value.

 \Drupal::service('site_config.service')->setValue('foo', 'field_1', 'value'); 

Sets a field value programmatically.

Depends on

Dependencies of the latest stable release

  • language Drupal core

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
7
Tracked since
Oct 2024
Latest release
7 months ago
Releases (12 mo)
5 ▲ from 2
Maintenance
Slowing

Release Timeline

Releases

Version Type Core Release date
1.0.1 Stable 10–11 Jan 30, 2026
1.0.0 Stable 10–11 Jan 27, 2026
1.0.0-rc10 Pre-release 10–11 Jan 20, 2026
1.0.0-rc9 Pre-release 10–11 Dec 26, 2025
1.0.0-rc8 Pre-release 9–11 Dec 19, 2025
1.0.0-rc7 Pre-release 9–10 Oct 24, 2024
1.0.0-rc6 Pre-release 9–10 Oct 11, 2024