Site sets

New in version 13.1

Site sets have been introduced.

Site sets ship parts of the site configuration as composable pieces. They are intended to deliver settings, TypoScript and page TSconfig for the scope of a site.

Extensions can provide multiple sets in order to ship presets for different sites or subsets (think of frameworks) where selected features are exposed as a subset (example: typo3/seo-xml-sitemap).

Site set definition

A site set definition contains the configuration for site settings, TypoScript and PageTSConfig and can be assigned to one or more sites via the site module. Site set definitions are created in the Configuration/Sets/ directory and separated from each other by a sub-folder with any name. In this way, it is also possible to create several site set definitions per extension. Each of these sub-folders must have a config.yaml that assigns at least a unique name and preferably also a unique label to the site set definition.

EXT:my_extension/Configuration/Sets/MySet/config.yaml
name: my-vendor/my-set
label: My Set
settings:
  website:
    background:
      color: '#386492'
dependencies:
  - my-vendor/my-other-set
  - other-namespace/fancy-carousel
Copied!
Line 1: name: my-vendor/my-set
Site Set Name Similar to the package name of Composer: [Vendor]/[Package] Is required to uniquely identify the site set and to resolve dependencies to other site sets. This name does NOT reflect an extension, but only the provider of an extension through the vendor name. There are NO conclusions from the name here as to which extension provided the site set definition.
Line 2: label: My Set
This label will be used in the new select box of the site module. Should be as unique as possible to avoid duplication in the site module.
Line 3-6: Settings
Define settings for the website Never nest settings with a dot! e.g. website.background.color Otherwise the new settings definitions will not work later. If a setting value contains special characters or spaces, it is recommended to wrap the value in single quotes. You can also define settings in a separate file settings.yaml. See section below.
Line 7: Dependencies
Load setup.typoscript, constants.typoscript, page.tsconfig and config.yaml from the site set definitions of this or other extensions. These dependencies are loaded before your own site set. For example a dependency to a site set definition in your own site package and/or a dependency to a site set definition from another provider (vendor)

Hidden site sets

Sets may be hidden from the backend set selection in Site Management > Sites and the console command bin/typo3 site:sets:list by adding a hidden flag to the config.yaml definition:

EXT:my_extension/Configuration/Sets/MyHelperSet/config.yaml
name: my-vendor/my-helperset
label: A helper Set that is not visible inside the GUI
hidden: true
Copied!

Integrators may choose to hide existing sets from the list of available sets for backend users via user TSconfig, in case only a curated list of sets shall be selectable:

EXT:my_extension/Configuration/user.tsconfig
options.sites.hideSets := addToList(typo3/fluid-styled-content)
Copied!

Using a site set as dependency in a site

Sets are applied to sites via dependencies array in site configuration:

config/sites/my-site/config.yaml
base: 'https://example.com/'
rootPageId: 1
dependencies:
  - my-vendor/my-set
Copied!

Site sets can also be added to a site via the backend module Site Management > Sites.

Settings definitions

Settings can be defined in a file called settings.definitions.yaml in a set, for example EXT:my_extension/Configuration/Sets/MySet/settings.definitions.yaml.

Read more about Site settings definitions.

Settings have a default value that can be overridden within a set.

Override site settings defaults in a subsets

Settings for subsets (for example to configure settings in declared dependencies) can be shipped via settings.yaml when placed next to the set file config.yaml.

Note that default values for settings provided by the set do not need to be defined here, as defaults are to be provided within settings.definitions.yaml.

Here is an example where the setting styles.content.defaultHeaderType as provided by typo3/fluid-styled-content is configured via settings.yaml:

EXT:my_extension/Configuration/Sets/MySet/settings.yaml
styles:
  content:
    defaultHeaderType: 1
Copied!

This setting will be exposed as site setting whenever the set my-vendor/my-set is applied as dependency to a site configuration.

TypoScript provider

TypoScript dependencies can be included via set dependencies. This mechanism is much more effective than the previous static includes or manual @import statements.

TypoScript dependencies via sets are automatically ordered and deduplicated.

Set-defined TypoScript can be shipped within a set. The files setup.typoscript and constants.typoscript (placed next to the config.yaml file) will be loaded, if available. They are inserted (similar to static_file_include) into the TypoScript chain of the site TypoScript that will be defined by a site that is using sets.

Set constants will always be overruled by site settings. Since site settings always provide a default value, a constant will always be overruled by a defined setting. This can be used to provide backward compatibility with TYPO3 v12 in extensions, where constants shall be used in v12, while v13 will always prefer defined site settings.

In contrast to static_file_include, dependencies are to be included via sets. Dependencies are included recursively. This mechanism supersedes the previous include via static_file_include or manual @import statements as sets are automatically ordered and deduplicated. That means TypoScript will not be loaded multiple times, if a shared dependency is required by multiple sets.

Page TSconfig provider

Page TSconfig is loaded from a file page.tsconfig, if placed next to the site set configuration file config.yaml and is scoped to pages within sites that depend on this set.

Therefore, extensions can ship page TSconfig without the need for database entries or by polluting global scope when registering page TSconfig globally via ext_localconf.php or Configuration/page.tsconfig. Dependencies can be expressed via sets, allowing for automatic ordering and deduplication.

Analyzing the available site sets via console command

A list of available site sets can be retrieved with the console command bin/typo3 site:sets:list:

vendor/bin/typo3 site:sets:list
Copied!
typo3/sysext/core/bin/typo3 site:sets:list
Copied!

Example: Using a set within a site package

You can see an example of using a sets within a site package in the extension t3docs/site-package (Source on GitHub).

The site package example extension has the following file structure:

  • Configuration

    • Sets

      • SitePackage

        • config.yaml
        • constants.typoscript
        • page.tsconfig
        • settings.yaml
        • setup.typoscript
      • ...
  • Resources

    • ...
  • composer.json
  • ...

Defining the site set with a fluid_styled_content dependency

As our example site package only contains one site set the name of that set is the same as the Composer name of the site package.

The site package depends on EXT:fluid_styled_content. Therefore the two sets provided by that system extension are included as dependencies:

EXT:site_package/Configuration/Sets/SitePackage/config.yaml
name: t3docs/site-package
label: 'Site Package'
dependencies:
  - typo3/fluid-styled-content
  - typo3/fluid-styled-content-css
Copied!

If you need additional dependencies, you can find all available sets with the console command bin/typo3 site:sets:list.

Using the site set as dependency of a site

After the example site package is installed, you can include the site set in your site configuration:

config/sites/<some_site>/config.yaml | typo3conf/sites/<some_site>/config.yaml
base: 'https://site-package.ddev.site'
dependencies:
  - t3docs/site-package
rootPageId: 1
Copied!

Loading TypoScript via the site package's set

The example site package also loads its TypoScript by placing the files constants.typoscript and setup.typoscript into the folder of the site set. These TypoScript files use @import statements to import files from the extension's directory Configuration/TypoScript:

EXT:site_package/Configuration/Sets/SitePackage/setup.typoscript
@import './TypoScript/*.typoscript'
@import './TypoScript/Navigation/*.typoscript'
Copied!

Dependant TypoScript is included by the dependant sets and not by TypoScript imports.

Using the site set to override default settings

In this example the file EXT:site_package/Configuration/Sets/SitePackage/settings.yaml is used to override default settings made by the by the set of EXT:fluid_styled_content:

EXT:site_package/Configuration/Sets/SitePackage/settings.yaml
styles:
    templates:
        layoutRootPath: EXT:site_package/Resources/Private/ContentElements/Layouts
        partialRootPath: EXT:site_package/Resources/Private/ContentElements/Partials
        templateRootPath: EXT:site_package/Resources/Private/ContentElements/Templates
    content:
        textmedia:
            maxW: 1200
            maxWInText: 600
            linkWrap:
                lightboxEnabled: true
                lightboxCssClass: lightbox
Copied!

Example: Providing a site set in an extension

Non site-package extensions can also provide site sets. These can be used by sites or site sets to include dependant TypoScript and settings.

The example extension t3docs/blog-example offers one main site set and several site sets for special use-cases. It has the following file structure:

  • Classes

    • ...
  • Configuration

    • Sets

      • BlogExample

        • config.yaml
        • constants.typoscript
        • page.tsconfig
        • setup.typoscript
      • DefaultStyles

        • config.yaml
        • setup.typoscript
      • RssFeed

        • config.yaml
        • constants.typoscript
        • setup.typoscript
      • ...
  • Resources

    • ...
  • composer.json
  • ...

Multiple site sets to include separate functionality

The main site set of the extension has the same name like the Composer name:

EXT:blog_example/Configuration/Sets/BlogExample/config.yaml
name: t3docs/blog-example
label: Blog example set
Copied!

The other two sets depend on this set being loaded and therefore declare it as dependency:

EXT:blog_example/Configuration/Sets/DefaultStyles/config.yaml
name: t3docs/blog-example-styles
label: Blog example default styles
dependencies:
  - t3docs/blog-example
Copied!
EXT:blog_example/Configuration/Sets/RssFeed/config.yaml
name: t3docs/blog-example-rss
label: Blog example RSS feed
dependencies:
  - t3docs/blog-example
Copied!

The additional site sets provide TypoScript configuration that depends on the base site set. They do not use @include statements to include the base TypoScript. The dependencies defined in the site set take care of the correct loading order of the TypoScript.

Site Set PHP API

Site

The site settings can be read out via the site object:

$color = $site->getSettings()->get('website.background.color');
Copied!

If a settings definition exists for this setting, the returned value has already been validated, converted and, if not set, the default value is used.

SetRegistry

The \TYPO3\CMS\Core\Site\Set\SetRegistry retrieves the site sets found in an ordered sequence, as defined by dependencies in config.yaml. Please preferably use the site object to access the required data. However, if you need to query one or more site set definitions in order as defined by dependencies, then SetRegistry is the right place to go. To read all site set definitions, please use \TYPO3\CMS\Core\Site\Set\SetCollector .

getSets

Reads one or more site set definitions including their dependencies.

$sets = $setRegistry->getSets('my-vendor/my-set', 'my-vendor/my-set');
Copied!

hasSet

Checks whether a site set definition is available.

$hasSet = $setRegistry->hasSet('my-vendor/my-set');
Copied!

getSet

Reads a site set definition WITHOUT dependencies.

$set = $setRegistry->getSet('my-vendor/my-set');
Copied!

SetCollector

TYPO3 comes with a new ServiceProvider, which goes through all extensions with the first instantiation of the SetCollector and reads all site set definitions found.

public function __construct(
    #[Autowire(lazy: true)]
    protected SetCollector $setCollector,
) {}
Copied!

However, this is not the official way to access the site set definitions and their dependencies. Please access the configuration via the site object. Alternatively, you can also use the SetRegistry , as only this manages the site sets in the order declared by the dependency specification.

Only use the SetCollector if you need to read all site set definitions. Dependencies are not taken into account here.