17

I wonder if there is a good writeup on Drupal directory structure?

24

I haven't seen one, so let's start a list right here. In Drupal 5, 6 and 7 the structure looks like this:

  • includes - include files with php functions and classes that make up the Drupal API
  • misc - miscellaneous assets like javascript files and images
  • modules - Drupal core modules (not meant for contrib and custom modules)
  • profiles - installation profiles
  • scripts - shell scripts for developers and administrators
  • sites - all files that are added by a developer to create a site

    • sites/all/libraries - 3rd party libraries, eg. a wysiwyg editor
    • sites/all/modules - contributed and custom modules
    • sites/all/themes - contributed and custom (sub)themes
    • sites/default - contains the default settings.php
    • sites/default/files - the default directory for user-uploaded files
    • sites/example.com/modules - the site-specific modules directory in a multisite structure
    • sites/example.com/themes - the site-specific themes directory in a multisite structure
    • sites/example.com/files - the site-specific directory for user-uploaded files in a multisite structure
  • themes - Drupal core themes
7

My first answer was true for Drupal 7 and below. Meanwhile, big change has been committed for Drupal 8 and up. Most core files now live in a 'core' folder. You can read more about it in this blog post or the original issue on drupal.org.

The new structure looks like this:

  • core - contains all files and folders that make up Drupal core (ie. the part you should not hack)
    • core/includes - include files with php functions and classes that make up the Drupal API
    • core/misc - miscellaneous assets like javascript files and images
    • core/modules - Drupal core modules (not meant for contrib and custom modules)
    • core/scripts - shell scripts for developers and administrators
    • core/themes - Drupal core themes
  • profiles - installation profiles
  • sites - all files that are added by a developer to create a site

    • sites/all/libraries - 3rd party libraries, eg. a wysiwyg editor
    • sites/all/modules - contributed and custom modules
    • sites/all/themes - contributed and custom (sub)themes
    • sites/default - contains the default settings.php
    • sites/default/files - the default directory for user-uploaded files
  • 3
    This answer is not complete at the moment, because Drupal 8 has progressed and now contains directories like /code/vendor and the re-purposed /modules and /themes. If anyone has a good overview of the current state of Drupal 8, please feel free to update the answer. – marcvangend Mar 25 '13 at 9:04
  • The drop is always moving! – geerlingguy Sep 5 '13 at 15:11
2

The accepted answer is good. This is just my two cents to expand other answers, as a site developer on Drupal 7. It is easier to navigate when upgrading many custom modules, few features, and parent/custom sub-themes.

  • sites/all
    • /modules
      • /contrib
      • /custom
      • /features
    • /libraries
    • /themes
  • sites/example.com
    • same as sites/all/* with site-instance specific needs when appropriate
  • I want exactly the same thing on Drupal 7 that you have mentioned in your answer but i am wondering how can i install new module in sites/all/modules/custom directory. Please help on this. – Bhavik Shah Nov 21 '13 at 7:11
  • I really havent tried placing modules to custom directory with drupal ui (ftp). I just ftp/ssh them there directly or assign it in makefile. As a sidenote installation and making module available are different thing as latter implies system modifications. – user20301 Nov 24 '13 at 18:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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