I would like to use a custom template for my taxonomy term pages. I attempted doing so by creating a hook in template.php like so

function mythemename_preprocess_page(&$variables){
    if($hook == 'node'){
        if(arg(0) == 'taxonomy'){
            $vars['template_file'] == 'node-taxonomy';

And then creating a custom template called node-taxonomy.tpl.php

However the page does not change.

I understand that I can achieve something similar using views, but since other sites are using different themes on our drupal instance I'd prefer not to change anything that relies on those views.

  • Your PHP code is incorrect in multiple places. What are you trying to do - provide custom templates for node.tpl.php or page.tpl.php on taxonomy pages? Commented Mar 25, 2016 at 20:07
  • Yes that is the intention
    – Amy
    Commented Mar 25, 2016 at 20:08

2 Answers 2


Theme hook suggestions are made based on these factors, listed from the most specific template to the least. Drupal will use the most specific template it finds:

  • taxonomy-term--tid.tpl.php
  • taxonomy-term--vocabulary-machine-name.tpl.php
  • taxonomy-term.tpl.php

Note that underscores in a vocabulary's machine name are replaced by hyphens.

  • Is there a way to specify a template for a specific taxonomy term view mode without display suite? I used hook_entity_info_alter to add a view mode to taxonomy terms. Now i need to assign a template to that view mode?
    – oll
    Commented Jun 19, 2017 at 13:59

In addition and for those who need, you can provide template suggestions for taxonomy terms that way :

function hook_theme_suggestions_taxonomy_term_alter(&$suggestions, $vars, $hook) {
  $term = $vars['elements']['#taxonomy_term'];
  $sanitized_view_mode = strtr($vars['elements']['#view_mode'], '.', '_');
  $suggestions[] = 'taxonomy_term__' . $term->bundle() . '__' . $sanitized_view_mode;
  $suggestions[] = 'taxonomy_term__' . $term->id() . '__' . $sanitized_view_mode;
  $suggestions[] = 'taxonomy_term__' . $sanitized_view_mode;

  return $suggestions;

It will provide, e.g. :


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.