How to add other types of dynamic attributes in the BODY tag? i have this code to include node-ID attributes to the body tag on the page. My question is ... how can i modify this code to get additional dynamic attributes for the BODY class? The most important for me are classes for the current vocabulary and taxonomy term, possibly a panel page.. I has been searching for few days and found only solution for node-ID.

Thank you many times for help.

 /**
 * Implements hook_preprocess_html().
 */
function enar_preprocess_html(&amp;$variables) {
  $node = \Drupal::request()-&gt;attributes-&gt;get('node');
  if ($node) {
    $variables['attributes']['class'][] = 'page-node-' . $node-&gt;id();
    if (empty($node-&gt;get('body')-&gt;value)) {
        $variables['attributes']['class'][] = 'no-padding-main-content';
    }
  }



   // Don't display the site name twice on the front page (and potentially others)
  if (isset($variables['head_title_array']['title']) &amp;&amp; isset($variables['head_title_array']['name']) &amp;&amp; ($variables['head_title_array']['title'] == $variables['head_title_array']['name'])) {
    $variables['head_title'] = $variables['head_title_array']['name'];
  }


  // Preloader configuration
  $preloader = theme_get_setting('preloader');
  $variables['attributes']['class'][] = $preloader;
  $variables['preloader'] = $preloader;
  // Go to top configuration
  $goto = theme_get_setting('gototop');
  $variables['goto'] = $goto;
}
I think, i found the right solution below:

  if ($node) {
    $variables['attributes']['class'][] = 'page-node';
}


  if ($tid) {
    $variables['attributes']['class'][] = 'term-page';
}  

  if ($tid) {
    $variables['attributes']['class'][] = 'term-page-' . $tid-&gt;id();
}