How can I tell if I'm on a taxonomy page in preprocess_page? If I'm on a node, inside preprocess_page(&amp;$variables), I can check

if (isset($variables['node']) &amp;&amp; $variables['node']-&gt;bundle() == 'my-type')

to see if I'm on a node, and a node of a certain type.

Then I can get field information with

$variables['node']-&gt;field_icon-&gt;entity-&gt;getFileUri()


How can I do the same thing for a taxonomy term page to know that I'm on a taxonomy term page and get the field values?
Unfortunately I don't think there is anything that the hook gives you directly that you can use in this instance. However you can always check the route name to determine if you are on a taxonomy term page.  

// Will be "true" if you are currently on a taxonomy term page.
if (\Drupal::routeMatch()-&gt;getRouteName() == 'entity.taxonomy_term.canonical') {

  // Since this is a taxonomy term page, you may wish to get the term ID.
  $term_id = \Drupal::routeMatch()-&gt;getRawParameter('taxonomy_term');
}