Empower themes to prevent base theming

Created on 11 March 2023, over 1 year ago
Updated 15 March 2023, over 1 year ago

Problem/Motivation

While base theming is an important piece of the Drupal theming ecosystem, it's not unheard of for themes to state they do not support base theming. Olivero, for example, has chosen not to support base theming in an effort to prevent breaking other themes when styles, scripts, or templates need to be updated. Bartick, even, explicitly states that it does not support base theming.

Without a way to actually prevent base theming, however, theme maintainers are left to field support questions when changes end up breaking other themes and seeking ways to alert theme developers that their actions lead them down a dangerous path such as in Warn users attempting to use Olivero as a base theme Needs work

With the introduction of the starterkit tool, it's reasonable for themers to prefer themes get extended one way over another, and they'll need a way to enforce that preference.

Proposed resolution

Create a new key in THEME.info.yml files that when set can prevent the theme from being used by Drupal as a base theme. For example, the "extendable" key in the info.yml file below:

name: Olivero
type: theme
base theme: false # Indicates this theme does not use a base theme
extendable: false # Indicates other themes may not use this theme as a base theme
description: 'A clean, accessible, and flexible Drupal front-end theme.'
package: Core
version: VERSION

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Feature request
Status

Active

Version

10.1

Component
Theme 

Last updated about 19 hours ago

Created by

🇺🇸United States andy-blum Ohio, USA

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @andy-blum
  • 🇺🇸United States andy-blum Ohio, USA
  • 🇬🇧United Kingdom dreamleaf

    I see the logic and thinking behind this, but is this not effectively making Drupal harder to work with?

    The ability to subtheme means that a person doesn't need to understand everything a base theme is doing, to sometimes just make trivial styling changes. I get that Olivero is intended to be a showcase of what is possible and that's great, but it's also a bit misleading if that is the face of Drupal and people can't easily customise it without knowing the nuts and bolts.

    Starterkit goes some way to providing an abstracted version of a theme, but it still doesn't solve the barrier to entry issue - which subtheming provides.

    Agency and enterprise will likely be creating themes from scratch, and have no need for subtheming - unless they are avoiding reinventing the wheel (ie using bootstrap or another framework base theme).

    The introduction of Single Directory Components Add Single Directory Components as a new experimental module Fixed (if this gets approved) could also go some way to providing a respectable answer to disallowing subtheming while still allowing overriding of components. So, assuming that goes ahead, maybe there should be a suggestion that if a theme is disallowing subtheming, it still provides a method for customisation.

Production build 0.71.5 2024