Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • Defining *.info.yml files in Drupal 8 theming

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.03k
    Comment on it

    Drupal 8 has come up with flexible and easier manners of theming from its previous versions.

    In Drupal 8 theme the first requirement is .info.yml file which contains the meta-data of theme.

    This file must be present in your theme folder because of which the theme gets appear at the admin side in Manage > Appearance.

    Lets see how we can define .info.yml file.

    1. In Drupal root folder locate /themes folder.

    2. In that theme folder in your custom theme create the file

    Add the below code in the file :


    name: mytheme
    description: My first Drupal 8 theme.
    type: theme
    base theme: classy
    core: 8.x
    version: VERSION
      - mytheme/global-styling
        header: Header
        primary_menu: 'Primary menu'
        secondary_menu: 'Secondary menu'
        breadcrumb: Breadcrumb
        help: Help
        highlighted: Highlighted
        content: Content
        sidebar_first: 'Left sidebar'
        sidebar_second: 'Right Sidebar'
        footer: Footer
        page_top: 'Page top'
        page_bottom: 'Page Bottom'


    Lets define the key/value pair we have used in above code which contains meta-data of theme.

    name : the name key is the one which will appear on the Appearance page. At the time of the theme activation.
    It's a required key.

    description : Description is also the one which will appear on the Appearance page.
    It's a required key.

    type : The type key indicated the whether its a theme or module extension. For theme it should be set to "Theme".
    It's a required key.

    base theme : The base theme defines which theme resource are needed to inherit i.e., to inherit the theme. there are two type of core themes in drupal 8 "stable" and "classy". If we wont define any it takes "stable" as default theme.

    core : This key specifies the compatible version of the core drupal for our theme.
    It's a required key.

    version : The version key specifies the version number for modules hosted on  

    libraries : The libraries contain the both css and javascript files call that we include in our theme. In info.yml file we declare the libraries which we need to activate.

    regions : It specifies the list of the regions. The content region should be there. If you do not declare any region into .info.yml file then the core regions will get enabled.

    Some optional keys we can use as per requirement

    regions_hidden : It allowed us to remove the regions that are coming from the base theme.

    The libraries-override and libraries-extend are the keys that are required to control the components of the library and to remove or add elements.

    ckeditor_stylesheets : this key allows us to have custom ckeditor styles attached the theme.

    That's all for the .info.yml file which helps in defining the meta-data of the theme.

 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: