print custom image field for taxonomy page (page--taxonomy.html.twig) template How do I load an image from a taxonomy custom field into a custom location on the taxonomy page template?

It's easy to accomplish it when the image is in a node. The following code works for images, but it doesn't work for taxonomy pages.

    {{ file_url(node.field_reference_background.entity.uri.value) }}


How can I accomplish the same for taxonomy pages?
Only entities from type node are loaded in the page template by default. If you want this for other entity types you have to add custom code to page preprocess:

function mytheme_preprocess_page(&amp;$variables) {
  if (\Drupal::routeMatch()-&gt;getRouteName() == 'entity.taxonomy_term.canonical') {
    $term = \Drupal::routeMatch()-&gt;getParameter('taxonomy_term');
    $variables['term'] = $term;
  }
}


Then you can access the fields from the term in page--taxonomy.html.twig:

{{ file_url(term.field_image.entity.uri.value) }}