HOWTO: Adding node type class to body element in Drupal 8

HOWTO: Adding node type class to body element in Drupal 8

Method 1: edit your html.html.twig theme template

Add this line at   <body{{ attributes.addClass(classes,:

    node_type ? 'page-node-type-' ~ node_type|clean_class

For example:

  <body{{ attributes.addClass(classes,
    not is_front ? 'with-subnav',
    sidebar_first ? 'sidebar-first',
    sidebar_second ? 'sidebar-second',
    (sidebar_first and not sidebar_second) or (sidebar_second and not sidebar_first) ? 'one-sidebar',
    (sidebar_first and sidebar_second) ? 'two-sidebars',
    (not sidebar_first and not sidebar_second) ? 'no-sidebar',
    node_type ? 'page-node-type-' ~ node_type|clean_class
  ) }}>

Method 2: Try node_type_class module

 

joan dj., 05/01/2017 - 21:41