Drupal custom page template based on the title of the page I have the following page:

About us


Whose path is:

site.com/node/6


Theme suggestions for the template files are:

page--node--6.tpl.php
page--node.tpl.php


You should already know that it is too weird to create custom template files based on the node's id, thus I like to have my custom page template based on the page's title (of course, converted to machine name, for instance "About us" to be "about-s"). What should I do?
I don't think this is an optimal solution at all, because node titles can easily be changed (and duplicated), but here you go:

function MY_THEME_preprocess_node(&amp;$vars) {
  // This assumes that you are using Pathauto for generating clean URLs.
  // Get the "clean" title.
  $title = pathauto_cleanstring($vars['node']-&gt;title);
  // Replace all dashes with underscores. This is necessary for recognizing the
  // template filenames.
  $title = str_replace('-', '_', $title);
  // Add new template variation.
  $vars['theme_hook_suggestions'][] = 'node__' . $title;
}


Note: to make this bulletproof for different languages, alphabets and special characters, make sure you have the Transliteration module installed and set to transliterate strings prior to creating URL aliases. This way if a node title has non-standard character (e.g. Č) it will be transliterated to Latin alphabet (in this case C).