Defining a theme with an .info.yml file

To create a Drupal 8 theme you need to first create a file that provides meta-data about your theme to Drupal. This is similar to how modules and installation profiles are being defined, and as such it is important to set the 'type' key in the .info.yml file to 'theme' in order to differentiate it.

This page provides an example file, and an overview of the information that the file can contain.

Let Drupal 8 know about your module with an .info.yml file

Main topic described: project metadata

An essential part of a Drupal 8 module, theme, or install profile is the .info.yml file (aka, "info yaml file") to store metadata about the project.

These .info.yml files are required to:

  • Notify Drupal about the existence of a module, theme or install profile.
  • Provide information for the Drupal Web UI administration pages.
  • Provide criteria to control module activation and deactivation and Drupal version compatibility.
  • General administrative purposes in other contexts.


The following is a sample .info.yml file:

name: Example Module
description: Example Module description.
package: Custom
type: module
version: 1.0
core: 8.x
  - node
configure: example.admin_index

The .info.yml file should have the same unique name as the .module file (if any) and reside in the same directory. For example, if your module is named "Example," and has a example.module file, then your .info.yml file should be named



Looking at the example info.yml file above lets take a look at each line to see what it does.

Modernizr.load() and Drupal: Basics

Modernizr can also be a conditional resource loader, which means it can load different CSS or JS files based on the outcome of Modernizr tests. This capability is only present when you have selected Modernizr.load on the download builder. The Drupal module automatically requires that this script loader be present in your build, so that the following API calls work no matter what.

Once you have Modernizr.load() available, the Modernizr module offers multiple ways to create Modernizr.load() commands. No matter how you create them, the Modernizr.load objects will all print out on your page in the exact spot they should be, coming after the Modernizr <script> tag but before most of the page markup, meaning they begin to be fetched as soon as possible.

The Modernizr module collects calls to this API from three places:

Default .info values

The following are the assumed defaults. When they are not defined, the theme will automatically take these values.
Default values are defined in _system_rebuild_theme_data().

Note: These defaults apply as a group. In other words, overriding a region with regions[sub_header] = Sub-header will omit the rest of the default regions. To gain them back, they must be redefined. This also applies to stylesheets. Even though it's not technically in a group, defining another stylesheet will prevent "style.css" from being included unless it is redefined.

Writing theme .info files

The .info file is a static text file for defining and configuring a theme. Each line in the .info file is a key-value pair with the key on the left and the value on the right, with an "equals sign" between them (e.g. name = my_theme). Semicolons are used to comment out a line. Some keys use a special syntax with square brackets for building a list of associated values, referred to as an "array". If you are unfamiliar with arrays, have a look at the default .info files that come with Drupal and read the explanations of the examples that follow. Even though the .info file extension is not natively opened by an Application, you can use TextEdit on a Mac or Notepad on a Windows computer in order to view, edit, and save your changes.

Note that this page describes .info files used for Drupal themes, and not modules. For information about the structure of .info files for Drupal modules, see Writing .info files in the Module developer's guide.


The following example shows the Drupal 6 .info file for the Garland theme:

name = Garland
description = Tableless, recolorable, multi-column, fluid width theme (default).
version = VERSION
core = 6.x
engine = phptemplate
stylesheets[all][] = style.css
stylesheets[print][] = print.css

Theme name requirements

The name should start with an alphabetic character, can contain numbers and underscores, but not hyphens, spaces or punctuation. The name will be used by Drupal in forming various functions in PHP and therefore it has the same limitations.

Do not choose names that are already used by installed modules, as all installed components must have unique names.

One of the best practices is to use prefixes when naming a site's custom theme, to guarantee unique names for themes. A site named might use theme names such as ex_themename.

Because the .info file is cached, you must clear the cache before any changes are displayed in your site.

The .info file can also specify which theme settings should be accessed from the Drupal administration interface, as you will soon see.

Overview of theme files

A theme is a collection of files that define the presentation layer. You can also create one or more "sub-themes" or variations on a theme. Only the .info file is required, but most themes and sub-themes will use other files as well. The following diagram illustrates the files that are found in a typical theme and sub-theme.

Drupal 6

theming requirements

Drupal 7

drupal 7 theme templates

Subscribe with RSS Subscribe to RSS - .info files