Define a theme using file .info.yml
To create a Drupal 8 theme, you must first create a THEMENAME.info.yml file that provides metadata about your theme in Drupal. This is similar to how modules and installation profiles are defined, so it's important to set the "type" key in the file.info.yml as "theme" to differentiate it.
This page contains an example of a THEMENAME.info.yml file and an overview of the information it may contain.
Create the .info.yml file
Create a .info.yml file at the root of your theme’s folder. The folder should have the same name as the .info.yml file. So if your theme is named "Fluffiness", the folder is called "fluffiness/", and the .info.yml file is "fluffiness/fluffiness.info.yml". If the file is present with the minimum required properties (name, type, and core), your theme will appear on your website under "Manage > Appearance" (http://example.com/admin/appearance). Be sure to choose a theme name that is not already used by another module or theme. The theme name must be unique within the Drupal configuration, otherwise the theme's components won't load correctly.
Replace spaces in the theme name with underscores in the folder name (and the .info.yml filename).
If you're not familiar with the YAML file format, read this brief introduction to YAML syntax.
- TABS are NOT allowed. Use ONLY spaces.
- Properties and lists MUST be indented with two (2) spaces.
Example
name: Fluffiness type: theme description: 'A cuddly theme that offers extra fluffiness.' core: 8.x libraries: - fluffiness/global-styling base theme: classy regions: header: Header content: Content sidebar_first: 'Sidebar first' footer: Footer
On your Drupal site, you can find more examples of .info.yml files by looking at core-provided themes. For example, open the folder core/themes/stark and look for the stark.info.yml file.
Key/Value Pairs
The following key/value pairs provide metadata about your theme and define some core functionality. (See \Drupal\Core\Extension\InfoParserInterface::parse().)
- name (required): Human-readable name shown on the Appearance page.
- type (required): Must be "theme". Case-sensitive.
- description (optional): Description shown on the Appearance page.
- package (optional): Groups themes into a package.
- core (required): Drupal core version compatible with the theme.
- php (optional): Minimum PHP version required. Defaults to DRUPAL_MINIMUM_PHP.
- version (optional): Theme version. Omit for Drupal.org-distributed themes.
- libraries (optional): Libraries (CSS/JS) added globally when the theme is active.
- libraries-override (optional): Collection of libraries/assets to override.
- libraries-extend (optional): Additional libraries added when a library is included.
- base theme (recommended): Inherit resources from another theme.
- hidden (optional): Hide the theme from the Appearance UI.
- engine (optional): Theme engine (default is "twig").
- logo (optional): Path to the logo relative to the .info.yml file.
- screenshot (optional): Path to the screenshot used in the Appearance UI.
- regions (optional): List of block regions defined by the theme.
- regions_hidden (optional): Inherited regions to remove.
- features (optional): Features to expose in the theme's settings page.
- stylesheets-remove (not recommended): Remove specific stylesheets from all pages.
- ckeditor_stylesheets (optional): Stylesheets to be loaded into the CKEditor iframe.
More Information
Drupal’s online documentation is © 2000-2020 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.