Drupal 7 themes directory structure

What is this article about?

In this article we will see how to place template files in manageable way, so that template files can be found easily.

How to organize template(.tpl.php) files?

Drupal searches everything under your theme's root (the folder with the .info and template.php file) folder. Therefore your folder structure can be whatever you like, drupal will simply recursively scan your theme folder until it finds the template file its looking for. This feature can be used to manage template files. Here is a Sample directory structure which I use:


Above directory structure contains templates directory with sub-directories with same name as of modules. Using this directory structure I can easily find module related .tpl.php files. So if I want to look for node tpl of particular content type I will go to templates/node instead of looking for it under each directory.

You can keep contributed themes under contrib directory & your custom themes under custom directory to make it manageable & easily accessible.

What we learnt?

Using proper directory structure can help us make the theme more manageable & easily accessible.