Introduction
Holy is a Drupal starter theme. It styles a standard Drupal installation out of the box and is meant to be the starting point of your own project theme: you clone it, give it a new name and change it as you like. The theme follows the principles of atomic design, ships a set of Single Directory Components and comes with a modern frontend toolchain (Sass, Vite, Tailwind CSS, linters) and a GitLab CI pipeline.
This guide is written for developers who know the web technologies (HTML, CSS, Sass, JavaScript, PHP, Node.js) but have not worked with Drupal much. Drupal specific terms are explained in Drupal basics for newcomers and in the Glossary.
| Property | Value |
|---|---|
| Machine name | holy |
| Drupal core | 11.3 or newer, 12 (core_version_requirement: ^11.3 || ^12) |
| Base theme | none (base theme: false), Holy is a standalone theme generated from core's Starterkit |
| Composer package | drupal/holy |
| Project page | https://www.drupal.org/project/holy |
| Source code | https://git.drupalcode.org/project/holy |
| Node.js (development only) | 20.19 or newer, 22 recommended (.nvmrc) |
| License | GPL-2.0-or-later |
Drupal basics for newcomers
A short overview of how Drupal renders a page and where a theme fits in. Details are in the official Theming Drupal guide.
- Modules and themes. Modules add functionality (content types, views, forms), themes control the HTML output and the look. Each extension is a folder with a
*.info.ymlfile. Core extensions live inweb/core, downloaded ones inweb/modules/contribandweb/themes/contrib, your own inweb/modules/customandweb/themes/custom. - Render arrays and templates. Drupal builds every page as a tree of PHP arrays (render arrays). Each piece (a page, a region, a block, a node, a field, a form element) is rendered by a Twig template. Core and modules provide default templates, a theme overrides them simply by placing a file with the same name anywhere in its folder.
- Template suggestions. Drupal looks for several candidate template names from the most specific to the most generic, e.g.
node--article--teaser.html.twig,node--article.html.twig,node.html.twig. The first one found wins. See Twig template naming conventions. - Hooks and preprocess. A theme reacts to Drupal events with hooks: methods of classes in
src/Hook/marked with the#[Hook('...')]attribute.preprocess_HOOKhooks prepare variables for templates before they are rendered,theme_suggestions_HOOK_alterchanges the list of template suggestions,form_FORM_ID_alterchanges forms. Older themes use procedural functions in aTHEME.themefile, which is deprecated since Drupal 11.5 and removed in Drupal 13. - Regions and blocks. A theme declares regions (header, content, footer...) in its
*.info.yml. Site builders place blocks (menus, branding, search form, views) into regions on the Block layout page (/admin/structure/block). - Libraries. CSS and JavaScript are never linked directly in templates. They are grouped into libraries in
THEME.libraries.ymland attached globally (in*.info.yml) or on demand ({{ attach_library('THEME/LIBRARY') }}). Drupal aggregates and orders them. - Single Directory Components (SDC). A component is a folder with a Twig template, a
*.component.ymldefinition (props and slots) and optional CSS and JS that Drupal attaches automatically whenever the component is rendered. - JavaScript behaviors. Drupal's JavaScript does not use
DOMContentLoadeddirectly. Code is wrapped inDrupal.behaviors.NAME.attach(context), which runs on page load and again after every AJAX update, andonce()makes sure an element is processed only once. - Configuration. Site settings (block placements, menus, content types) are stored as configuration, exportable to YAML files. A theme can ship default configuration in
config/installorconfig/optional. - Cache. Drupal caches discovered templates, libraries, components and rendered output. After changing Twig, YAML or PHP files run
drush cr(cache rebuild). Use the Twig development mode for local work (see below). - Tools. Composer downloads Drupal, modules and themes, Drush is the Drupal command line (cache clear, enabling extensions, config), DDEV is a popular Docker based local environment.
Technologies
Overview of everything the theme uses, grouped by purpose. Versions of the Node.js tools are pinned in package.json and package-lock.json.
Drupal
| Technology | Used for | Documentation |
|---|---|---|
| Drupal theming | Theme definition, regions, libraries, template overrides. | Theming Drupal Defining a theme with an .info.yml file Adding assets via *.libraries.yml |
| Twig | All HTML templates (templates/, components/). |
Twig documentation Twig in Drupal |
| Single Directory Components | Reusable components in components/. |
Using Single Directory Components |
| Starterkit theme | Holy was originally generated from core's Starterkit. It does not depend on Starterkit: the styles of the former Starterkit libraries (files, progress bar, node, indented comments, search results) are in the theme's own Sass. | Starterkit theme |
| JavaScript API | Drupal.behaviors and once() in js/ and component scripts. |
JavaScript API overview |
| Drupal coding standards | PHP, JavaScript, CSS and Twig conventions enforced by the linters. | Drupal coding standards |
Styles
| Technology | Used for | Documentation |
|---|---|---|
| Sass (SCSS) | All theme and component styles. Compiled by sass-embedded (Dart Sass), the module system @use / meta.load-css is used, no @import. |
Sass documentation |
| Atomic design | Organization of the Sass sources into base, atoms, molecules, organisms, templates and pages. | Atomic Web Design |
| CSS cascade layers | Each atomic level is a @layer, so a later level wins regardless of selector specificity. |
MDN: @layer |
| CSS container queries | Content in the main column and the sidebars adapts to the width of its column, not the viewport (@container). Query containers: .site-main (main), sidebars (sidebar), the comments section, pager and local tasks. Breakpoints $container-* (480, 640, 800px). Page chrome (navbar, header, menu, footer, page grid) keeps @media. |
MDN: Container queries |
| CSS custom properties | Colors and breakpoints from sass/_variables.scss are exposed as --primary, --gray-50... in css/root.css. |
MDN: Using CSS custom properties |
| BEM | Class naming in templates (.comment__author, .main-menu__link--level-2). |
getbem.com |
| Tailwind CSS 4 | Utility classes prefixed with tw: (tw:text-center), generated only for classes used in templates/ and components/. |
Tailwind CSS documentation |
| PostCSS | Post-processing of the compiled CSS. | postcss.org |
| postcss-pxtorem | Converts px to rem (1rem = 16px), except in media queries. |
github.com/cuth/postcss-pxtorem |
| Autoprefixer | Adds vendor prefixes based on Browserslist defaults. | github.com/postcss/autoprefixer |
| postcss-sorting | Sorts declarations into a fixed property order (position, display, box model, typography...). | github.com/hudochenkov/postcss-sorting |
| Web fonts | Self-hosted Nunito Sans and Geologica (WOFF2, Latin and Cyrillic subsets) in fonts/, declared in sass/fonts.scss. |
MDN: @font-face |
Build and tooling
| Technology | Used for | Documentation |
|---|---|---|
| Node.js and npm | Runs the frontend tools. Only needed for development, a production server does not need Node.js because the compiled CSS is committed. | nodejs.org npm docs |
| nvm | Optional Node.js version manager, reads .nvmrc. |
github.com/nvm-sh/nvm |
| Vite | Build tool: compiles Sass and Tailwind to CSS, watch mode. | vite.dev |
| BrowserSync | Used by npm run watch: proxies the Drupal site, injects rebuilt CSS and reloads the page after a template or script change. |
browsersync.io |
| fast-glob | Finds Sass entry files and expands folder imports in the Vite config. | github.com/mrmlnc/fast-glob |
| Composer | Installs the theme and the PHP tools (Coder, PHPStan) in the Drupal project. | getcomposer.org |
| Drush | Drupal command line: cache rebuild, enabling the theme. | drush.org |
| DDEV | Recommended local environment (Docker). All commands can be run inside it. | ddev.com |
Code quality
| Technology | Used for | Documentation |
|---|---|---|
| Stylelint | SCSS linting, rules based on Drupal core plus limits for nesting and selector length. | stylelint.io |
| ESLint | JavaScript linting following the Drupal JavaScript coding standards. | eslint.org |
| Prettier | Formatting of SCSS, JavaScript and the generated CSS. | prettier.io |
| CSpell | Spell check (US English) of code, comments and templates. | cspell.org |
| PHP_CodeSniffer + Drupal Coder | PHP coding standards (Drupal, DrupalPractice). | PHP_CodeSniffer drupal.org/project/coder |
| PHPStan | Static analysis of PHP, level 5. | phpstan.org |
| GitLab CI (drupal.org templates) | Automated checks for every push and merge request on drupal.org. | GitLab CI templates |
| EditorConfig | Shared editor settings (2 spaces, LF, UTF-8). | editorconfig.org |
Theme structure
holy/
├── holy.info.yml theme definition, regions
├── holy.libraries.yml CSS/JS libraries
├── src/Hook/ PHP hooks as classes (preprocess, suggestions, settings form)
├── src/ThemeCloner.php the Clone theme tool
├── config/optional/ default block placements
├── config/schema/ configuration schema of the theme settings
├── templates/ Twig template overrides
│ ├── block/ content/ content-edit/ dataset/ field/ form/
│ └── layout/ misc/ navigation/ user/ views/
├── components/ Single Directory Components
│ └── <component>/
│ ├── <component>.component.yml
│ ├── <component>.twig
│ ├── <component>.css generated from sass/
│ ├── <component>.js optional
│ ├── sass/ component Sass sources
│ ├── templates/ optional Drupal template overrides
│ └── images/ optional
├── sass/ Sass sources (atomic design)
│ ├── _variables.scss
│ ├── base/ atoms/ molecules/ organisms/ templates/ pages/
│ ├── base.scss templates.scss atoms.scss molecules.scss
│ ├── organisms.scss pages.scss root.scss fonts.scss ckeditor.scss
│ └── tailwind.css
├── css/ compiled CSS (generated, committed)
├── js/ theme JavaScript (Drupal behaviors)
├── fonts/ self-hosted WOFF2 fonts
├── images/ icons and images used in CSS
├── scripts/ helper scripts for npm
├── tests/ PHPUnit tests (Functional, Unit)
├── doc/ this documentation
└── package.json, vite.config.js, ... frontend tooling
Regions
Regions are declared in holy.info.yml and printed in templates/layout/page.html.twig. Empty regions are not rendered.
| Machine name | Label | Placement in the page |
|---|---|---|
navbar | Navbar | Mobile top bar with the hamburger button (.site-navbar). |
header | Header | Header, usually the site branding (.site-header). |
header_menu | Header menu | Header, e.g. language switcher and user account menu. |
header_search | Header search | Header, search form. |
menu | Menu | Main navigation bar (.site-menu). |
breadcrumb | Breadcrumb | Hidden on the front page. |
title | Title | Page title inside main, hidden on the front page. |
content | Content | Main content (.site-main). |
sidebar_first | Primary sidebar | Left sidebar (.site-sidebar-first). |
sidebar_second | Secondary sidebar | Right sidebar (.site-sidebar-second). |
footer | Footer | .site-footer |
copyright | Copyright | Bottom bar (.site-copyright). |
The center wrapper gets one of the classes no-sidebars, one-sidebar sidebar-first, one-sidebar sidebar-second or two-sidebars, depending on which sidebars have content.
A menu block that renders no items on the current page (e.g. the sidebar menu on a page without a submenu) is removed in preprocess_page, and so is a region left without blocks. Without this, the region would not be empty in page.html.twig (blocks are rendered later through placeholders) and an empty sidebar would take a column.
Sidebar menu. The block holy_sidebar_menu shows the main menu from the second level in the sidebar_first region, so it appears only in sections with a submenu. Its heading is the first-level item of the current section, linked to the section page (any menu block starting below the first level with a visible label gets this heading). It uses the core menu block, no contrib module is needed. Styles: sass/organisms/sidebar/_sidebar-menu.scss.
Language switcher. On a multilingual site (Language module with at least two languages) the block holy_languageswitcher shows the interface language switcher in the header_menu region, before the user account menu. Links show the language code (EN, CS); screen readers get the language name in the language itself (preprocess_links__language_block). Styles: sass/organisms/header/_header-language.scss.
About Holy block. The block holy_about shows a short description of the theme with links to the project page, issue queue, source code and demo site, only on the front page, in the sidebar_second region. A theme cannot provide a block plugin and a custom block (block_content) is content, not configuration, so the text lives in the header of the view views.view.holy_about, which lists no rows. Edit the text in Views (/admin/structure/views/view/holy_about), translate it with Configuration translation. Styles: sass/organisms/block/_block-holy-about.scss.
Templates
templates/ contains overrides of core templates, grouped into folders the same way as in core's Starterkit. The folder names are only for orientation, Drupal finds a template by its file name anywhere inside the theme.
| Folder | Content |
|---|---|
layout/ | html.html.twig (the HTML document), page.html.twig (page layout and regions), region.html.twig, maintenance-page.html.twig. |
block/ | Block wrappers: branding, menus, search form, local tasks and actions. |
content/ | Nodes (full, teaser), comments, taxonomy terms, page title, search results. |
content-edit/ | Content editing forms: node edit form, file and image widgets, text format help. |
dataset/ | Tables and item lists. |
field/ | Field wrappers and formatters (image, file, link, time, text). |
form/ | Form elements: input, select, textarea, checkboxes, radios, fieldset, details... |
navigation/ | Menus, breadcrumb, pager, local tasks (tabs), vertical tabs. menu--main--menu.html.twig renders the main menu in the menu region with the main_menu component. |
misc/ | Status messages, progress bar. |
user/ | User profile and user name. |
views/ | Views output: unformatted list, grid, table, exposed filters, mini pager. |
Finding the right template
Turn on Twig development mode at /admin/config/development/settings (local environment only). Drupal then prints HTML comments with the template used for every part of the page and the list of possible file names (suggestions), and it stops caching templates. To override a template, copy it from core (e.g. web/core/modules/node/templates/node.html.twig) or from Starterkit (web/core/themes/starterkit_theme/templates/) into templates/, rename it to the suggestion you need and run drush cr.
Holy adds one suggestion of its own: menus placed as blocks get a suggestion with the region name, menu--<menu>--<region>.html.twig (implemented in src/Hook/ThemeHooks.php). This is why menu--main--menu.html.twig applies only to the main menu in the menu region, while the same menu in the footer uses the default menu.html.twig.
Components
Each folder in components/ is a Single Directory Component. Its ID is holy:<file name of the .component.yml>, e.g. holy:main_menu. Drupal attaches <name>.css and <name>.js from the component folder automatically; extra dependencies are declared under libraryOverrides. A component is rendered from Twig with:
{{ include('holy:main_menu', { items: items, attributes: attributes }, with_context = false) }}
A component can also contain a templates/ folder with Drupal template overrides that map Drupal data (a node, a view) to the props and slots of the component, so everything that belongs to one feature stays in one folder.
| Component | Group | Description |
|---|---|---|
main_menu | Navigation | Main navigation: dropdowns on hover and focus on desktop, collapsible submenus on mobile. |
Sass structure
Styles follow atomic design. Every level has its own entry file, compiles into its own CSS file and is a cascade layer. The order of the layers is declared once in sass/base.scss:
@layer base, atoms, molecules, organisms, templates, pages;
templates only places the regions (.site-*, .region-*, .layout) with layout properties (display, grid, order, width, gap, padding, container...) and never styles what is inside them, so it does not override the components. The .container is an atom, so organisms can change its padding.
| Source | Content | Output |
|---|---|---|
sass/_variables.scss | Sass variables: colors, screen and container breakpoints. No CSS output. | - |
sass/root.scss | Variables exposed as CSS custom properties on :root. | css/root.css |
sass/fonts.scss | @font-face declarations. | css/fonts.css |
sass/base/ | Reset, html, body. | css/base.css |
sass/atoms/ | Typography, media, form elements, buttons, icons, container. | css/atoms.css |
sass/molecules/ | Breadcrumb, tabs, pager, form items, fields, messages, details... | css/molecules.css |
sass/organisms/ | Regions (header, navbar, footer, sidebar), node, comment, blocks, views, dialogs. | css/organisms.css |
sass/templates/ | Page layout: columns, sidebars. | css/templates.css |
sass/pages/ | Page specific styles (search, user login, registration, password reset). | css/pages.css |
sass/ckeditor.scss | Typography inside the CKEditor 5 editing area. | css/ckeditor.css |
sass/tailwind.css | Tailwind CSS entry: tw: prefix, sources to scan, theme colors and breakpoints. | css/tailwind.css |
components/*/sass/ | Component styles. | components/*/*.css |
How the cascade works in Holy:
- A later layer overrides an earlier one regardless of specificity (
pagesbeatsorganisms, which beatsmolecules...). - CSS outside any layer beats all layers: Drupal core and module CSS, component CSS and Tailwind utilities. A
tw:class in a template therefore always wins over the theme styles. - Selectors are still kept flat and low in specificity: no ID selectors, at most 3 nesting levels and 4 compound selectors (enforced by Stylelint). Use BEM classes and the region classes from
page.html.twig(.site-header,.site-main,.site-footer...). - A variant goes after its base styles, ideally in the same file.
Conventions for Sass files:
- Files starting with
_are partials and do not produce their own CSS file. - A partial that needs variables loads them with
@use "../variables" as *;(path relative to the partial). - Entry files load whole folders with a glob, e.g.
@include meta.load-css("atoms/**/*");. Partials are included in alphabetical order. Sass itself does not support globs, the Vite config expands them (see Build pipeline).npm run devwatches the folders, so adding, removing or moving a partial rebuilds the entry. url()paths are written relative to the generated CSS file (e.g.url("../images/search.svg")insass/) and stay unchanged in the output.
Tailwind CSS
Tailwind is used only as a utility layer next to the Sass styles:
- Every class has the
tw:prefix (tw:text-center,tw:md:flex), so it never collides with Drupal classes such as.block,.hiddenor.container. - Preflight (Tailwind's reset) is not loaded, the theme has its own reset in
sass/base/_reset.scss. - Colors and breakpoints come from the theme variables:
tw:text-primary,tw:bg-gray-90; breakpointssm(480px),md(850px),lg(1360px). Tailwind's default palette is switched off. - Tailwind scans
templates/andcomponents/and generates only classes it finds written out in full. Never build a class name from parts ('tw:h-' ~ height). Map prop values to full class names instead:
{# Tailwind only generates classes written out in full, keep these maps literal. #}
{% set aligns = {
left: 'tw:text-left',
center: 'tw:text-center',
right: 'tw:text-right',
} %}
<div class="text {{ aligns[text_align] ?? '' }}">...</div>
After adding or removing a tw: class in Twig run npm run build (or keep npm run dev running), otherwise the class is missing in css/tailwind.css.
Libraries
Defined in holy.libraries.yml:
| Library | Content | Attached |
|---|---|---|
holy/global-styling | All files from css/ (in the order fonts, root, base, atoms, molecules, organisms, templates, pages, tailwind) and js/navbar.js. | On every page (holy.info.yml). |
The keys base, layout, component and theme in the library definition are Drupal's CSS groups (based on SMACSS); Drupal outputs them in this order. css/ckeditor.css is loaded into the CKEditor 5 editing area through ckeditor5-stylesheets in holy.info.yml, so editors see content styled like on the website.
JavaScript
Theme scripts are plain JavaScript without a build step, written as Drupal behaviors:
/**
* @file
* Support for navbar-collapse with navbar icon-menu.
*/
((Drupal, once) => {
Drupal.behaviors.navbarCollapse = {
attach(context) {
once('navbarCollapse', '.icon-menu', context).forEach((iconMenu) => {
iconMenu.addEventListener('click', () => {
const open = document.body.classList.toggle('menu-open');
iconMenu.setAttribute('aria-expanded', open ? 'true' : 'false');
});
});
},
};
})(Drupal, once);
js/navbar.js opens and closes the mobile menu. Component scripts (main_menu.js) live in their component folders. Every file starts with a @file docblock (required by ESLint).
Default configuration
config/optional/ contains block placements (block.block.holy_*.yml) that Drupal imports when the theme is installed: branding in the navbar, header and footer, main menu, sidebar menu (main menu from the second level), language switcher, the About Holy block on the front page (with its view views.view.holy_about), footer menu, user account menu, search form, breadcrumb, page title, messages, help, local tasks, main content and "Powered by Drupal". Configuration in optional (unlike install) is imported only if its dependencies exist, e.g. the language switcher needs the Language module, and the search block: Drupal 12 removed the Search module from core, it is available as a contrib module. After installation the blocks are regular configuration and can be changed at /admin/structure/block.
Root files
Files in the root folder of the theme.
Drupal files
| File / folder | Purpose |
|---|---|
holy.info.yml | Theme definition, required by Drupal: name, description, supported core versions, base theme (none), regions, global libraries and the CKEditor 5 stylesheet. Changes need drush cr; adding or removing regions moves blocks, so check the block layout afterwards. |
holy.breakpoints.yml | Breakpoints for responsive image styles: holy.mobile, holy.md (850px), holy.lg (1360px), multipliers 1x, 1.5x, 2x. |
holy.libraries.yml | Asset libraries (CSS and JS), see Libraries. |
src/Hook/ThemeHooks.php | Hooks as a class (Drupal\holy\Hook\ThemeHooks, registered automatically as a service): preprocess_page removes menu blocks without items (and regions left empty), preprocess_block and theme_suggestions_menu_alter add the per region menu suggestions and the section heading of menu blocks starting below the first level, preprocess_links__language_block shortens the language switcher links to language codes, preprocess_image_widget hides the image preview for users without access. Replaces the former holy.theme file. See Hooks in themes can now be OOP. |
src/Hook/ThemeSettingsHooks.php | Implements form_system_theme_settings_alter: adds the Clone theme tool to the theme settings form (/admin/appearance/settings/holy), with its validate and submit handlers. Replaces the former theme-settings.php. |
src/ThemeCloner.php | Copies the theme and replaces its name, used by the Clone theme tool. |
config/schema/holy.schema.yml | Configuration schema of the theme settings (holy.settings). Drupal validates saved configuration against it, without it saving the settings fails in tests. |
logo.svg | Default site logo, used by the branding block unless a custom logo is uploaded in the theme settings. |
screenshot.png | Theme preview on the Appearance page. |
composer.json | Composer package definition: drupal/holy, type drupal-theme, so Composer installs it to web/themes/contrib/holy. |
LICENSE.txt | GNU GPL version 2 or later, the license of all Drupal projects. |
README.md | Short reference for developers. |
CHANGELOG.md | Notable changes per release, breaking changes first. |
AGENTS.md | Instructions for AI coding agents: English only in the source, commands, workflow rules. |
Frontend tooling
| File | Purpose |
|---|---|
package.json | npm scripts (dev, build, lint, fix, spellcheck...), required Node.js version (engines) and the development dependencies. |
package-lock.json | Exact versions of all dependencies. Commit it, install with npm ci to get the same versions everywhere. |
.nvmrc | Recommended Node.js major version (22) for nvm use and the CI image. |
.npmrc | engine-strict=true: npm refuses to install with an unsupported Node.js version. |
vite.config.js | Build configuration, see Build pipeline. |
postcss.config.js | PostCSS plugins: px to rem, Autoprefixer, property sorting (with the full property order). |
stylelint.config.js | SCSS lint rules: stylelint-config-standard-scss plus rules taken over from Drupal core, allowed units, no IDs, nesting and selector limits, property order check. |
eslint.config.js | ESLint flat config: recommended rules, Drupal JavaScript coding standards, browser and Drupal globals (Drupal, drupalSettings, once), required @file docblock, Node.js globals for config files. |
.prettierrc.json | Prettier options: 80 characters, single quotes, trailing commas for JS; long lines and double quotes for CSS/SCSS. |
.prettierignore | Files Prettier does not check: node_modules/, generated CSS, package-lock.json, the script of the documentation template. |
scripts/check-node.cjs | Runs before the npm scripts (pre* hooks) and stops with a readable message when Node.js is older than 20.19. |
Code quality and CI
| File | Purpose |
|---|---|
phpcs.xml.dist | PHP_CodeSniffer rules: Drupal and DrupalPractice standards for PHP and YAML files. |
phpstan.neon | PHPStan configuration: level 5, scans the PHP files (src/, tests/). |
.cspell.json | Spell check configuration (US English, ignored paths, flagged words). Used by drupal.org CI. |
scripts/cspell.local.json | Local spell check: .cspell.json plus the Drupal core dictionaries, the same setup as in CI. |
.cspell-project-words.txt | Project specific words accepted by the spell check, one per line. |
tests/ | PHPUnit tests, see Tests. |
.gitlab-ci.yml | GitLab CI pipeline on drupal.org, see Continuous integration. |
.editorconfig | Editor settings: UTF-8, LF, 2 spaces, final newline, no trailing whitespace (4 spaces for composer.json). |
.gitignore | Excludes node_modules/ from git. |
.vscode/ | Recommended VS Code extensions (EditorConfig, ESLint, Stylelint, Prettier, PHP CodeSniffer) and workspace settings matching the coding standards. |
Installation
Requirements
- Drupal 11.3 or newer, or Drupal 12, installed with Composer. 11.3 is the first version that supports hooks as classes in themes.
- For theme development only: Node.js 20.19 or newer (22 recommended) and npm.
Download the theme
Download the theme with Composer from the root of your Drupal project (the folder with composer.json and vendor/):
composer require drupal/holy
The theme is placed in web/themes/contrib/holy. With DDEV prefix the commands with ddev:
ddev composer require drupal/holy
Enable the theme
In the administration go to Appearance (/admin/appearance), find Holy and click Install and set as default. Or with Drush:
drush theme:enable holy
drush config:set system.theme default holy -y
drush cr
On installation Drupal imports the block placements from config/optional/. Check the result at Structure > Block layout (/admin/structure/block).
For a real project do not use Holy directly: create your own theme as a clone, so updates of Holy never overwrite your changes.
Set up the development tools
Needed only when you change styles or scripts. The compiled CSS is committed, so a production server needs neither Node.js nor a build.
cd web/themes/custom/CUSTOM_THEME
nvm install # optional, installs the Node.js version from .nvmrc
npm ci # installs the exact versions from package-lock.json
npm run build # compiles all styles
If the Node.js on your computer is older than 20.19, run the commands inside DDEV (the DDEV web container has a current Node.js):
ddev exec -d /var/www/html/web/themes/custom/CUSTOM_THEME "npm ci"
ddev exec -d /var/www/html/web/themes/custom/CUSTOM_THEME "npm run build"
The PHP checks and tests (npm run lint:php, npm run test) need PHPUnit, Drupal Coder and PHPStan in the project's vendor/. All of them come with drupal/core-dev:
composer require --dev drupal/core-dev
Cloning the theme
The recommended way to create your own theme is to clone Holy from its settings page. The clone is a standalone theme, not a sub-theme: it does not depend on Holy, so Holy can be updated or even removed without affecting your site. You own all the code of the clone and change it freely.
Why a clone and not a sub-theme? A sub-theme inherits templates, libraries and styles from its base theme, so every update of the base theme can change your site. A starter theme like Holy is meant to be copied once and then developed on its own; this is also how Drupal core's Starterkit works.
Create a clone
- Go to Appearance > Settings > Holy (
/admin/appearance/settings/holy). - Open the Clone theme section at the end of the form.
- Fill in the Theme name (human-readable, e.g. My Project). The Machine name is generated from it (e.g.
my_project) and can be edited: it must start with a letter and contain only lowercase letters, numbers and underscores, and it must not be used by another theme, module or profile. Optionally fill in the Description. - Press Create clone. You are redirected to the Appearance page, where you install the new theme and set it as default.
The web server must be able to write into web/themes/custom. Clone the theme in your local environment and commit the result to your project repository, not on a production server.
If the Clone theme section is missing after deploying a new version of Holy, run drush cr.
What the clone does
- Copies all files of the theme to
web/themes/custom/<machine_name>, except the.gitandnode_modulesfolders. - Renames files and folders containing
holy, e.g.holy.info.ymlbecomesmy_project.info.yml. - Replaces the theme name in the content of all text files (
.yml,.twig,.php,.scss,.css,.js,.json,.md,.svg,.txt...):holy→my_project(PHP namespaces such asDrupal\holy\Hook, librariesholy/global-styling, component IDsholy:main_menu, block configuration),-holy-→-my-project-(CSS classes and HTML IDs such asblock-holy-main-menu, where Drupal turns underscores into dashes),Holy→ the theme name,HOLY→ the theme name in upper case.
- Binary files (images, fonts,
screenshot.png) are copied unchanged. HTML files are copied too, but their content is not rewritten, so this documentation indoc/still talks about Holy. - Sets
nameanddescriptionin the new*.info.ymland removes the version information added by drupal.org packaging.
The compiled CSS is copied as well, so the clone works immediately, without running a build. The clone keeps the Clone theme tool, so it can be cloned again.
After cloning
cd web/themes/custom/my_project
drush theme:enable my_project
drush config:set system.theme default my_project -y
npm ci
npm run build
git init # or commit the folder to your project repository
Then adjust the clone to your project:
- Change colors and breakpoints in
sass/_variables.scss(breakpoints also insass/tailwind.cssandholy.breakpoints.yml); Tailwind colors insass/tailwind.cssfollow the CSS custom properties fromsass/root.scss, so a new color needs to be added in all three places. - Replace
logo.svg,screenshot.pngand the fonts. - Update
composer.json(package name, homepage) andpackage.json(name, author, version). - Remove components and templates you do not need.
Alternative: core Starterkit generator
Drupal core can generate a theme from any theme marked as a starterkit with a command line tool. Holy does not need it (the clone tool does the same from the UI), but for completeness:
php web/core/scripts/drupal generate-theme my_project
Without --starterkit this generates a theme from core's starterkit_theme, not from Holy. See Starterkit theme.
Automation
All automation is driven by npm scripts in package.json. Run them from the theme folder.
npm scripts
| Command | What it does |
|---|---|
npm ci | Installs the development dependencies exactly as in package-lock.json. |
npm run build | One-off build of all styles: sass/*.scss, sass/tailwind.css and components/*/sass/*.scss. |
npm run dev | Build and watch: rebuilds when a source file or a template with Tailwind classes changes. |
npm run watch | Same as npm run dev, plus browser reload: open the site at https://localhost:3000, see Browser reload. |
npm run lint | Stylelint and Prettier check for SCSS, ESLint and Prettier check for JavaScript. Changes nothing. |
npm run fix | Fixes what can be fixed automatically (Stylelint, ESLint) and formats the code with Prettier. |
npm run lint:php | PHP_CodeSniffer (Drupal, DrupalPractice) and PHPStan, using the tools from the project's vendor/bin. |
npm run fix:php | Fixes PHP coding standard violations with phpcbf. |
npm run spellcheck | CSpell with the Drupal core dictionaries and the project words. Optional, for manual use: it is slow and drupal.org CI checks spelling. |
npm run styleguide | Updates styleguide/index.html from the current state of the theme (run it after npm run build): the CSS links of the theme libraries and components, and the code samples marked with data-rwstyleguide-file. npm run styleguide -- --check only lists what is outdated. |
Every script first runs scripts/check-node.cjs (npm's pre* hooks), so an old Node.js fails with a clear message instead of a cryptic error.
Build pipeline
vite.config.js uses Vite only as a CSS compiler, there is no JavaScript bundling and no Vite dev server. What happens on npm run build:
- Entry points. Every Sass file that does not start with
_is an entry:sass/<name>.scss→css/<name>.csscomponents/<component>/sass/<name>.scss→components/<component>/<name>.csssass/tailwind.css→css/tailwind.css
- Folder imports. A small plugin expands
@include meta.load-css("dir/**/*");into onemeta.load-cssper partial, in alphabetical order. - Sass compilation with
sass-embedded. - Tailwind (
@tailwindcss/vite) scanstemplates/andcomponents/and generates the usedtw:utilities. - PostCSS (
postcss.config.js):px→rem, vendor prefixes, property sorting. - Unchanged URLs. Drupal serves the CSS from fixed paths, so
url()values must stay exactly as written. The config hides them from Vite's URL rewriting and restores them in the output; Vite does not copy any images or fonts. - Readable output. The generated CSS is not minified and is formatted with Prettier, so diffs of the committed CSS are easy to review. Drupal minifies and aggregates CSS itself in production (
/admin/config/development/performance). - Clean output. Empty JavaScript chunks that Vite creates for CSS entries are removed.
The generated files (css/*.css, components/*/*.css) are committed to git. Never edit them by hand, change the sources and run the build.
Browser reload
npm run watch runs the same watch build as npm run dev and starts BrowserSync (a plugin in vite.config.js, active only in this mode):
- The site is proxied to
https://localhost:3000and opened in the browser (turn it off withBROWSERSYNC_OPEN=0 npm run watch). BrowserSync uses its own self-signed certificate, so the browser asks once to accept it. - Rebuilt CSS is injected into the page without a reload.
- A change in
templates/**/*.twig,components/**/*.{twig,yml,js}orjs/**/*.jsreloads the page. Twig changes show up only with Twig development mode on. - The site URL is taken from
ddev describe, so run the command on the host, in the theme directory. Without DDEV set it yourself:BROWSERSYNC_PROXY=https://example.local npm run watch.
Testing in several browsers and devices
Every browser or device that opens the site through BrowserSync is connected to the same npm run watch: all of them get the injected CSS and reload together. BrowserSync also mirrors interaction between them (ghost mode): clicks, scrolling, navigation and form input made in one browser are repeated in the others.
Several browsers on the same computer. Open https://localhost:3000 in each browser (Chrome, Firefox, Edge...) and accept the self-signed certificate once in each of them.
Other devices (phone, tablet, another computer) must be on the same network. When it starts, BrowserSync prints two addresses:
[holy] Access URLs:
Local: https://localhost:3000
External: https://192.168.1.20:3000
Open the External address on the device and accept the certificate warning (Chrome: Advanced → Proceed, Safari: Show Details → visit this website). The device does not need to resolve the *.ddev.site domain, BrowserSync rewrites the links to its own address. If the page does not load, allow incoming TCP port 3000 in the computer's firewall.
WSL 2 (Windows). In the default NAT networking the External address is the internal address of the WSL virtual machine (e.g. 172.19.x.x), which other devices cannot reach. Choose one of these:
- Mirrored networking (Windows 11 22H2+, recommended): WSL shares the network interfaces of Windows, and the External address becomes the computer's address in the local network. Add to
%UserProfile%\.wslconfig:
run[wsl2] networkingMode=mirroredwsl --shutdown, start WSL again and allow incoming connections in PowerShell as administrator:
Restart Docker Desktop (or DDEV) afterwards if the site stops responding.Set-NetFirewallHyperVVMSetting -Name '{40E0AC32-46A5-438A-A0B2-2B479E8F2E90}' -DefaultInboundAction Allow New-NetFirewallRule -DisplayName "BrowserSync 3000" -Direction Inbound -Protocol TCP -LocalPort 3000 -Action Allow - Port forwarding (NAT networking): forward port 3000 of Windows to WSL in PowerShell as administrator, then open
https://<Windows IP>:3000on the device (the Windows address is inipconfig):
The WSL address (netsh interface portproxy add v4tov4 listenport=3000 listenaddress=0.0.0.0 connectport=3000 connectaddress=<WSL IP> New-NetFirewallRule -DisplayName "BrowserSync 3000" -Direction Inbound -Protocol TCP -LocalPort 3000 -Action Allowhostname -Iin WSL) changes after a restart of Windows, update the rule then (netsh interface portproxy delete v4tov4 listenport=3000 listenaddress=0.0.0.0and add it again).
Drupal caches. Other browsers and devices usually visit the site as an anonymous user, whose pages Drupal serves from the page cache. Besides Twig development mode, turn on Do not cache markup at /admin/config/development/settings, otherwise a template change shows up only after drush cr. Login sessions are not shared: log in on each device separately.
Debugging on a device. For the console and inspector of a mobile browser connect the device by USB: Chrome on Android via chrome://inspect on the computer, Safari on iOS via Develop menu of Safari on macOS (turn on Web Inspector in the iOS Safari settings). For a quick check of layouts use the device toolbar in the browser developer tools, but it does not replace a real device (touch, viewport height with browser bars, fonts, Safari rendering).
Linting and formatting
- Stylelint checks
sass/**/*.scssandcomponents/**/*.scss: Drupal core rules, allowed units, no ID selectors, at most 3 nesting levels and 4 compound selectors, property order. - ESLint checks
js/andcomponents/scripts against the Drupal JavaScript coding standards (curly,eqeqeq,no-var,prefer-const,@filedocblock...). - Prettier handles all formatting, ESLint and Stylelint only check code quality.
- PHP_CodeSniffer with Drupal Coder and PHPStan check
src/,tests/and the YAML files. Withdrupal/core-devPHPStan also reports deprecated Drupal APIs. - CSpell checks spelling in code, comments and templates. Add legitimate project words to
.cspell-project-words.txt.
With the recommended VS Code extensions (.vscode/extensions.json) the editor shows the same errors while you type.
Tests
tests/ contains PHPUnit tests in the standard Drupal layout (namespace Drupal\Tests\holy):
tests/src/Functional/HolyThemeTest.phpinstalls Drupal with Holy as the default theme and checks the result in a browser emulator: the page layout and regions, the global library, the main menu rendered by themain_menucomponent (and so the per region menu suggestion fromThemeHooks), a node page, the theme settings form and the validation of the Clone theme tool.tests/src/Unit/ThemeCloneTest.phprunsThemeCloneragainst a temporary directory and checks renamed files, replaced names in PHP, Twig and YAML, the updated.info.yml, excluded folders and unchanged binary files.
The tests are smoke tests: they catch a theme that breaks on a new Drupal version (removed APIs, Twig or library changes, PHP errors), not visual changes. Run them with:
cd web/themes/custom/CUSTOM_THEME
npm run test
# or with DDEV, from anywhere in the project
ddev exec -d /var/www/html/web/themes/custom/CUSTOM_THEME "npm run test"
npm run test runs core's PHPUnit (vendor/bin/phpunit -c web/core tests). The functional test needs a database and the site URL in SIMPLETEST_DB and SIMPLETEST_BASE_URL; the script defaults to the DDEV values (mysql://db:db@db/db, http://localhost), set the variables to run it elsewhere. Test tables use their own prefix, so the site database is not touched.
Continuous integration
.gitlab-ci.yml runs on drupal.org GitLab for every push and merge request. It includes the Drupal Association GitLab templates, which install Drupal with the theme and run:
- PHPCS (with
phpcs.xml.dist), - PHPStan (with
phpstan.neon), - CSpell (with
.cspell.jsonand.cspell-project-words.txt), - Twig CS Fixer,
- PHPUnit (
tests/) against the current Drupal 11 release.
The next major variant is switched on (OPT_IN_TEST_NEXT_MAJOR, _AUTORUN_NEXT_MAJOR): on every push and merge request the tests also run against the development branch of Drupal 12 with its minimum PHP version, so incompatibilities show up before Drupal 12 is released or updated.
The template ESLint and Stylelint jobs are switched off (SKIP_ESLINT, SKIP_STYLELINT), because they use core's tool versions and cannot load the theme's own configs. They are replaced by the theme-assets job (Node.js 22), which:
- installs the dependencies (
npm ci), - runs
npm run lint, - runs
npm run build, - fails when the generated CSS differs from the committed CSS (
git diff --exit-code -- css components). This catches commits where the sources were changed but the build was not run.
Development workflow
Everyday work
- Turn on Twig development mode and disable CSS aggregation locally (
/admin/config/development/settings,/admin/config/development/performance). - Run
npm run dev(ornpm run watchwith browser reload) and edit the sources:sass/,components/*/sass/,sass/tailwind.css, templates. - After changing
.twig,.ymlor PHP files rundrush cr(not needed for Twig with development mode on, but needed for new templates, libraries, components and hooks). - Before committing run
npm run lint, after PHP changesnpm run lint:php, after PHP, Twig or YAML changesnpm run test, andnpm run build. - Commit the sources together with the generated CSS.
Add a Sass partial
- Create the file in the right atomic level, e.g.
sass/molecules/_teaser-list.scss. - Nothing else is needed, the entry file loads the whole folder and
npm run devpicks up the new file.
Add a component
- Create
components/my_component/withmy_component.component.yml(name, props, slots; use the$schemaline from an existing component for editor validation) andmy_component.twig. - Put the styles into
components/my_component/sass/my_component.scss; the build createscomponents/my_component/my_component.css, which Drupal attaches automatically. - Optionally add
my_component.js(a Drupal behavior) and dependencies underlibraryOverrides. - Run
npm run buildanddrush cr, then use it:{{ include('holy:my_component', {...}, with_context = false) }}.
Override a template
- Find the template and its suggestions in the HTML comments (Twig development mode).
- Copy the original template into the matching folder in
templates/and rename it to the suggestion, e.g.node--article--full.html.twig. - Run
drush cr.
Add a region
- Add the region to
regionsinholy.info.yml. Listing regions replaces the default set, so keep all existing ones. - Print it in
templates/layout/page.html.twig({{ page.my_region }}). - Run
drush crand place blocks in the new region.
Troubleshooting
| Problem | Solution |
|---|---|
| A change in a template, YAML or PHP file has no effect. | Run drush cr. For templates enable Twig development mode. |
| A change in Sass has no effect. | Check that npm run dev is running and the CSS was regenerated; disable CSS aggregation or clear caches; reload without browser cache. |
npm run watch does not reload the page. | Open the site through https://localhost:3000, not its own URL. If the site URL cannot be detected, set BROWSERSYNC_PROXY. |
A new entry file (sass/*.scss without an underscore, components/*/sass/*.scss) is not compiled. | Restart npm run dev, entry files are collected when the build starts. New partials do not need a restart. |
A tw: class does nothing. | The class must be written out in full in templates/ or components/ and the build must run afterwards. Check the class exists in css/tailwind.css. |
Node.js ... is too old | Install Node.js 20.19+ (nvm install) or run the command in DDEV. |
CI job theme-assets fails with "Generated CSS is out of date". | Run npm run build and commit the changed CSS files. |
| The Clone theme section is missing. | Run drush cr. The section is shown on the settings page of Holy and of its clones. |
| Clone fails with "The directory themes/custom is not writable". | Create web/themes/custom and make it writable for the web server user (locally). |
npm run lint:php cannot find phpcs. | Install drupal/core-dev with Composer; the theme must be inside a Drupal project (web/themes/*/THEME). PHPStan also reports missing PHPUnit classes in tests/ without it. |
Glossary
| Term | Meaning |
|---|---|
| Block | A piece of content placed in a region (menu, branding, search form, view, custom text). |
| Block layout | Administration page where blocks are placed into regions, per theme (/admin/structure/block). |
| Behavior | Drupal's way to run JavaScript on page load and after AJAX (Drupal.behaviors). |
| Configuration | Site settings stored in the database and exportable to YAML. |
| Content type | A type of node (article, basic page) with its own fields. |
| Contrib | Modules and themes contributed by the community on drupal.org. |
| Drush | Drupal command line tool. |
| Library | A named group of CSS and JS files defined in *.libraries.yml. |
| Machine name | The internal name of an extension or entity (lowercase, underscores), e.g. holy. |
| Node | A piece of content (an article, a page). |
| Hook | A method (or in older code a function) Drupal calls at a given moment, e.g. preprocess_page before rendering the page template. In themes since Drupal 11.3 a method in src/Hook/ with the #[Hook] attribute. |
| Preprocess | A hook that prepares template variables (preprocess_HOOK). |
| Recipe | A package of modules and configuration applied to a site in one step. See Drupal recipes. |
| Region | A named area of the page layout declared by the theme. |
| Render array | A PHP array describing what to render; Drupal turns it into HTML using templates. |
| SDC | Single Directory Component: template, definition, CSS and JS in one folder. |
| Starterkit | Core theme used as a template to generate new themes. |
| Sub-theme | A theme that inherits from a base theme. Holy and its clones are not sub-themes. |
| Template suggestion | An alternative, more specific template name Drupal tries before the default one. |
| View | A configurable list of content built with the Views module (e.g. the News listing). |