Add content type machine name as body class Is there a way to insert a class to the body of the node page? It should be named like the current node type's machine name.

Maybe someone could extend this code below with a content type class:

function marienschule_preprocess_html(&amp;$variables) {

  // Add node ID to the body class.
  $node = \Drupal::routeMatch()-&gt;getParameter('node');
  if ($node) {
    $variables['attributes']['class'][] = 'node-' . $node-&gt;id();
  }
}
The code sample from your question could be extended to look like that:

function marienschule_preprocess_html(&amp;$variables) {

  $node = \Drupal::routeMatch()-&gt;getParameter('node');
  if ($node instanceof \Drupal\node\NodeInterface) {

    // Add node ID body class.
    $variables['attributes']['class'][] = 'node-' . $node-&gt;id();

    // Add content type machine name body class.
    $variables['attributes']['class'][] = 'node-type-' . str_replace('_', '-', $node-&gt;bundle());
  }
}