How can I dynamically add URL or taxonomy to body class Am creating my own theme and have successfully added the URL into the node class in node.html.twig with {% set classes = [ 'url' ~ url|clean_class, ] %} but I need to be able to style each page individually as a whole, not just at the node level - how do I add the URL or the taxonomy of the node to the page or body classes?
The answer provided by mradcliffe was what I needed. One improvement that will yield a css-friendly class name is to use the Twig |clean_class filter. Here is the code:

In MY_THEME.theme

&lt;?php
function MY_THEME_preprocess_html(&amp;$variables) {
  $current_path = \Drupal::service('path.current')-&gt;getPath();
  $variables['current_path'] = \Drupal::service('path.alias_manager')-&gt;getAliasByPath($current_path);
}
?&gt;


In html.html.twig:

{%
  set body_classes = [
    logged_in ? 'user-logged-in',
    not root_path ? 'path-frontpage' : 'path-' ~ root_path|clean_class,
    node_type ? 'page-node-type-' ~ node_type|clean_class,
    db_offline ? 'db-offline',
    current_path ? 'context' ~ current_path|clean_class,
  ]
%}
&lt;body{{ attributes.addClass(body_classes) }}&gt;


Don't forget to clear your cache!