Get current taxonomy in template_preprocess_html() I have a custom field on my taxonomy that I would like to access in template_preprocess_html(). How do I get the current taxonomy id, in Drupal 8, on a taxonomy listing page?
First, check if the route is for a taxonomy term; then, get the term ID.

if (\Drupal::routeMatch()-&gt;getRouteName() == 'entity.taxonomy_term.canonical') {
  $term_id = \Drupal::routeMatch()-&gt;getRawParameter('taxonomy_term');
}