Change record status: 
Project: 
Introduced in branch: 
8.x
Description: 

All of our old .info files have been converted to YAML and the old .info parser has been removed. The new parser is the Symfony YAML component. The new file extension is .info.yml. This applies to modules, themes, and profiles.

Overview

Syntax

  • For the most part, change all = to :.
  • For arrays (e.g. dependencies[] = node), use the following format in drupal 8:
    dependencies:
      - node
  • In drupal 7 we use  ; for   Comments And now in drupal 8 we use # for Comments.

More information on the YAML file format

New required 'type' key

A new type key is now required with values that indicate the type of extension. Use module, theme or profile. For example:

type: module

Remove files[] entries

Remove any files[] entries. Classes are now autoloaded using a separate mechanism: PSR-4 compatible class loader in core

Convert configure links to route names

In Drupal 8, specify the administrative configuration link using the route name instead of the system path.

Drupal 7

configure = admin/config/system/actions

Drupal 8

configure: action.admin

More information on the new routing system: hook_menu() has been replaced by new routing system

Examples

For a theme

Drupal 7

name = Bartik
description = A flexible, recolorable theme with many regions and a responsive, mobile-first layout.
package = Core
version = VERSION
core = 7.x

; Stylesheets
stylesheets[all][] = css/layout.css
stylesheets[all][] = css/style.css
stylesheets[all][] = css/colors.css
stylesheets[print][] = css/print.css

; Regions
regions[header] = Header
regions[help] = Help
regions[page_top] = Page top
regions[page_bottom] = Page bottom
regions[highlighted] = Highlighted

regions[featured] = Featured
regions[content] = Content
regions[sidebar_first] = Sidebar first
regions[sidebar_second] = Sidebar second

regions[triptych_first] = Triptych first
regions[triptych_middle] = Triptych middle
regions[triptych_last] = Triptych last

regions[footer_firstcolumn] = Footer first column
regions[footer_secondcolumn] = Footer second column
regions[footer_thirdcolumn] = Footer third column
regions[footer_fourthcolumn] = Footer fourth column
regions[footer] = Footer

; Settings
settings[shortcut_module_link] = 0

Drupal 8

name: Bartik
type: theme
description: 'A flexible, recolorable theme with many regions and a responsive, mobile-first layout.'
package: Core
version: VERSION
core: 8.x

# Stylesheets
stylesheets:
  all:
    - css/layout.css
    - css/style.css
    - css/colors.css
  print:
    - css/print.css

# Regions
regions:
  header: Header
  help: Help
  page_top: 'Page top'
  page_bottom: 'Page bottom'
  highlighted: Highlighted
  featured: Featured
  content: Content
  sidebar_first: 'Sidebar first'
  sidebar_second: 'Sidebar second'
  triptych_first: 'Triptych first'
  triptych_middle: 'Triptych middle'
  triptych_last: 'Triptych last'
  footer_firstcolumn: 'Footer first column'
  footer_secondcolumn: 'Footer second column'
  footer_thirdcolumn: 'Footer third column'
  footer_fourthcolumn: 'Footer fourth column'
  footer: Footer

# Settings
settings:
  shortcut_module_link: '0'

Example for Module

Drupal 8

hal.info.yml file

name: 'HAL'
type: module
description: 'Serializes entities using Hypertext Application Language.'
package: Web services
version: VERSION
core: 8.x
dependencies:
  - rest
  - serialization
Impacts: 
Module developers
Themers
Updates Done (doc team, etc.)
Online documentation: 
Not done
Theming guide: 
Not done
Module developer documentation: 
Not done
Examples project: 
Not done
Coder Review: 
Not done
Coder Upgrade: 
Not done
Other: 
Other updates done

Comments

jonesmac’s picture

Can the new yaml parsers handle scripts the same way the .info parser did?

jonesmac’s picture

It does work with scripts. I just needed to rebuild the theme registry to get it to work. I recommend adding a script example in the documentation so newbies like me don't have to ask :)

cam8001’s picture

This is going to be/has been removed in D8 to my knowledge. I'm suprised that it works at all, given Modules can no longer add stylesheets/scripts via their .info.yml file.

revagomes’s picture

According https://drupal.org/node/1876152 the removing of this feature was restricted to modules. Which means that themes still can add stylesheets and scripts via .info.yml files.

Keep in mind that people are whom will change the world. Stand up!
revagomes.com.br is powered by Drupal.

jnicola’s picture

So... what's the correct format to add JS in the theme?

stpaultim’s picture

I'm trying to figure out how "features" would be written in the new info.yml files. I can't find any examples to confirm or refute my assumptions and am not getting them to work as expected.

cweagans’s picture

If you post an example of your info file, I'll show how to convert it to YAML.

---
Cameron Eagans
http://cweagans.net

stpaultim’s picture

I'm trying to recreate a problem and identify the steps for an issue in the Drupal 8 issues queue.

* http://drupal.org/node/1006266#comment-7220016

The problem has to do with disabling the "logo" feature. I believe that to recreate the problem, I'd add this into the .info.yml file - make sure it works. Then remove the logo feature and see if it breaks.

Just want to be sure that I'm writing the features into the file correctly. This is how it would have been done in Drupal 7 ( Drupal 7 reference = http://drupal.org/node/171205 ).

features[] = logo
features[] = name
features[] = slogan
features[] = node_user_picture

FYI - The Zen theme (Drupal 7) actually has features enabled in the theme right out of the box.

cweagans’s picture

The proper way to write those lines would be:

features:
  - logo
  - name
  - slogan
  - node_user_picture

---
Cameron Eagans
http://cweagans.net

dreftymac’s picture

Great progress forward!

It is great to see this finally take root and grow after planting some of the initial seeds; starting the gears turning for the Drupal community back in November 2009 (although, there were those of us who saw the technical advantages several years before that).[fn001]

Even though there were and are contrary perspectives based at least partially on personal opinion[fn002], it is clearly a step forward for Drupal to include components, technologies and conventions that have a wide range of recognition along with a fully documented technical specification.

Congrats on the positive step forward!

mgifford’s picture

It's nice to have one for the themes laid out like this, but even having a simple one for modules could be useful.