Problem

  • The 99% use-case of Drupal is a single site without multi-site functionality — but yet, we throw that entire concept into everyone's face.

Goal

  • Simplify Drupal's directory layout for single-site installations.

Proposed solution

  1. Ditch /sites/all/* completely in favor of top-level /* directories.

    (Replace * with "modules", "themes", "profiles", etc.)

Related issues

Change notices to update

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sun’s picture

This patch reveals that I sneaked 99% of this change into core already. :-D

Love this patch.

sun’s picture

Status: Active » Needs review
Issue tags: +Needs architectural review
webchick’s picture

This makes me smile so hard. :)

quicksketch’s picture

Yay yay yay! Wow I can't believe all the pinnings are there already. Nice work on #562042: Search for install profiles in sites/[all|site]/profiles folders, and move core profiles into /core/profiles :D

I hope more justification isn't needed than sun has given already, but overall this is going to be HUGE win for new users to Drupal. Even today people are constantly putting modules and themes directly into the root /modules and /themes directories. Now that we've moved the root directories, people have no idea where modules and themes live at all (at least not without starting to dig through directories). Moving the end-user modules/themes to the root level let's people do what they've intuitively been wanting to do for years.

Bojhan’s picture

Awesome, thanks!

tim.plunkett’s picture

FileSize
14.16 KB

Tried to clean up references to sites/all.

So cool!

sun’s picture

Oh, awesome! Thanks @tim.plunkett! -- that's way more docs to update than I imagined :)

+++ b/README.txt
@@ -38,8 +38,7 @@ More about configuration:
- * Download contributed modules to sites/all/modules to extend Drupal's
-   functionality:
+ * Download contributed modules to modules to extend Drupal's functionality:

@@ -52,8 +51,7 @@ themes. More themes are available for download, and you can also create your own
- * Download contributed themes to sites/all/themes to modify Drupal's
-   appearance:
+ * Download contributed themes to themes to modify Drupal's appearance:

I think we need to prefix the directory with a slash in order to make any sense of the resulting sentences :)

+++ /dev/null
@@ -1,7 +0,0 @@
-This directory should be used to place downloaded and custom modules, themes
-and profiles which are common to all sites. Keeping contributed and custom

The sites/all/README.txt is definitely obsolete with this patch.

However, I wonder whether we want to move it into sites/README.txt instead?

Essentially, that new README.txt would be the ideal place to describe how the multi-site functionality works, how to enable it (if it needs to be enabled at some point in the future), and potentially even to move the 2 gazillion lines of comments about the settings.php discovery out of default.settings.php into it...? :)

webchick’s picture

Possibly, but the last time we touched that file it was 3+ months and 80+ comments so I'd recommend deferring that to a follow-up.

sun’s picture

Deferring that optimization to a follow-up makes sense, too. :)

That said, can we delete /core/modules/README.txt & Co with this patch?

Those clarifications (tl;dr: "This is core; don't fuck with me.") look unnecessary to me if there are top-level modules/themes/profiles directories already. (?)

webchick’s picture

No, unfortunately not because Git will not let you check in empty directories. :\ That's why they're there.

webchick’s picture

Oh, I'm sorry. /core/modules/README.txt. Yes, that's probably fine.

willvincent’s picture

Actually, any file in a directory will allow you to check in/out "empty" directories with Git. Even if those are blank files. If the whole purpose of a readme file is to be able to check in an otherwise empty directory, it might make sense to place an empty dot prefixed file there instead. Good options might be .empty, .blank, or .placeholder... or of course an empty .gitignore would also do the trick. :)

webchick’s picture

Right, that's true, but it doesn't hurt to put docs in here too to explain how the directories are working, so we went with that. sun's actually talking about different README.txt files though, which are in the *core* modules/ and themes/ directory and say basically "hey, buster don't put stuff here." That's no longer relevant when the top-level directories are the ones you should put your custom stuff into, as it will be after this patch. :) So those files in the core/ sub-directories can/should be removed.

aspilicious’s picture

I'm totally in for this. :D

sun’s picture

RTBC? :)

webchick’s picture

Can someone step through a D7 -> D8 upgrade path with some contributed modules/themes and see how that goes first?

Crell’s picture

This is going to be a huge pain for people managing multiple sites on different versions. The drush maintainers will probably kill you. I admit I'm not the "target audience" for this issue, but I've never really had a problem with /sites/ confusing me when building single-site installs.

(Although, disclaimer, I'm the one who added sites/all in the first place back in Drupal 5. :-) )

Grayside’s picture

Quick reaction..

  1. There is a simple beauty to mv sites elsewhere. Good for upgrades and backups.
  2. When you discover you want multi site, the transition process is already tricky. Starting with the idea
    of multisite when possible to avoids the mini migrations of, say, later APC optimization.
sun’s picture

re: #16: @webchick:

I can't think of any upgrade path failures due to this change. This is way less invasive than the /core directory change, and we're even able to handle that. ;) That is, especially because you ought to disable contributed modules in a major core upgrade... So, if there happen to be any issues, those are caused by something else.

re: #17: @Crell:

I don't see how this makes the situation any worse with regard to maintaining multiple major versions... the /core directory change is already in, which is the change that is truly troublesome. The entire point is that (novice) developers (mistakenly) [ab]used /modules for non-core modules in the past. Given that this [ab]use is even supported in D7, there's no real change here - /modules is still /modules, just no longer abusable — the only "real" change is the deprecation/removal of sites/all/modules, which just simply no longer makes sense, if you have a top-level /modules already.

That said, I'm perfectly aware that this change kinda leaves a "stray" /sites/default behind. However, @quicksketch already raised the idea elsewhere of whether we couldn't also move settings.php to the top-level (or alternatively, have a single /site directory — which sorta reminds of Symfony's /web and/or /Resources directory, in case that is an argument ;) ).

In the end though, this change makes Drupal site building much more easy to understand for newcomers, who have no interest in learning Drupal's multi-site capabilities, but instead want to understand how they can build Drupal sites.

re: #18: @Grayside:

You're making one good point there - sites/all allowed someone to easily move all modules/themes from the global directories into a different directory — be it for a major version upgrade path, or a delayed setup of multi-site functionality.

However, given that the actual difference just means to execute 3 moves instead of one, and that both use-cases are quite advanced, I don't think they play a significant role here. (That said, for a major core upgrade, you only need to disable non-core modules, not move them.)

rafamd’s picture

This change seems good for the not so experienced.
Leaving sites/default/settings.php behind doesn't sound that fine though. Easiest to find for beginners would be in the base directory, but I don't know if that's possible (permissions, etc ?)

What other uses are left for the /sites dir ?

pounard’s picture

Does this mean the sites/*/ will die? I have some multisites running, and it works very well, it's great a benefit when you have limited memory space for APC and such things.

mariomaric’s picture

@pounard: Hell no, just sites/all/*! :) Everything is explained in issue summary. :P

IMHO, this issue could benefit from more visibility.

My 2 cents: after some thoughts, personally I'm against this. I think it's really nice that all core files are in core/ folder, and having all site files sitting in sites/[all|default|XYZ] folder is consistent and convenient.

I think it would be great to just add in README.txt file one extra paragraph:

  • About Drupal
  • Folders/files structure
  • Configuration and features
  • Appearance
  • Developing for Drupal

explaining structure of folders and what goes where.

IMO with moving only sites/all/* folders without touching rest of sites/* will only bring inconsistency and bad UX (user = site builder).

sun’s picture

No, it just means that the directories in sites/all/* are moved to the top-level/root directory.

The multi-site functionality is not touched at all by the proposed change here. However, you might be interested in #1055862: Require sites.php to opt-in for multi-site support/functionality

pounard’s picture

Ok, thanks.

klonos’s picture

#562042: Search for install profiles in sites/[all|site]/profiles folders, and move core profiles into /core/profiles was recently fixed, but this issue here intents to move the /sites/[all|site]/* (including /sites/[all|site]/profiles) to the root of the directory structure.

I tried to understand from reading through this issue how the all vs. specific themes/modules/profiles will be separated once we implement this + #1055862: Require sites.php to opt-in for multi-site support/functionality but don't get it. Someone care to explain? Will it be:

/modules/all
/modules/specific-site
/themes/all
/themes/specific-site
/profiles/all
/profiles/specific-site

naxoc’s picture

@klonos
As I understand it, the "all" folder concept is to be completely removed. So modules and themes should normally go in /modules or /themes directly. That way all sites can use it. If there is a specific site that wants to override a module it would go in sites/specific-site/modules.

klonos’s picture

...ok so:

1. top-level modules/themes/profiles folders from D7 (that were used for core modules/themes/profiles) were moved under /core for D8.
2. sites/all/* were moved to top level, thus recreated the top-level modules/themes/profiles folders the were (re)moved in step 1 - only this time they'll be used for non-core modules/themes/profiles.
3. for site-specific modules/themes/profiles in D8 users will have to create themselves a sites/[site-name] directory (or will the D8 folder structure already include a "sites" top-level directory?) and place them there.

Right?

naxoc’s picture

@klonos Yes, that is how I understand it.

More work on moving also settings.php to the drupal root is going on over at #760992: Where should site specific modules, themes and settings be kept?.

klonos’s picture

Thanx ;)

lpalgarvio’s picture

i like it the way klonos described it.
a lot of documentation will have to be changed and some notices will have to be visible somewhere

sun’s picture

Can we move forward here?

If there are still concerns about removing support for sites/all/*, then I'd suggest to just simply not remove that discovery path from drupal_system_listing() - but still create the new top-level directories for freshly installed sites. In essence, we don't really care and if some people find sites/all/* more attractive than top-level directories for whatever reason in their custom setup, then they could happily use them.

If that's what it takes to get this patch in, then I will happily do that minimal adjustment/revert to the patch.

lpalgarvio’s picture

don't forget Libraries dir during planing, as Libraries API might still get in time for core 8.
#667058: Add a libraries folder with a README.txt in it to DRUPAL_ROOT
#1167496: Libraries API in core

let me throw in some wood to the fire...
there has been in the past the discussion about using /contrib dir in place of /sites/all dir, as a solution that solves the problem underneath, but does not cause confusion (like the whole deal of /modules stated as "core alert, dont' hack" since old times) to current drupal users.

i'll revive it briefly, perhaps not with many arguments just yet, but instead with directory schematics:

current D8 scheme (/sites/all/*):

core/ * drupal core only
    includes/
    lib/
    misc/
    modules/
    profiles/
    scripts/
    themes/
    vendor/
sites/ * contrib files and site specific files
    all/ * all contrib files, not specific to a site
        libraries/
        modules/
        profiles/
        themes/
    default/
    www.example.com/

proposed change - plan A (/sites/all/* -> /*):

core/ * drupal core only
    includes/
    lib/
    misc/
    modules/
    profiles/
    scripts/
    themes/
    vendor/
libraries/ * all contrib libraries, not specific to a site
modules/ * all contrib modules, not specific to a site
profiles/ * all contrib profiles, not specific to a site
themes/ * all contrib themes, not specific to a site
sites/ * site specific files
    default/
    www.example.com/

proposed change - plan B (/sites/all/* -> /contrib/*):

core/ * drupal core only
    includes/
    lib/
    misc/
    modules/
    profiles/
    scripts/
    themes/
    vendor/
contrib/ * all contrib files, not specific to a site
    libraries/
    modules/
    profiles/
    themes/
sites/ * site specific files
    default/
    www.example.com/

as you can see, plan B, might create a little more organization, clarity, simplify documentation... added to less confusion caused to old drupal users _and_ a clear correlation to contrib vs core vs user space.

sun’s picture

Libraries are irrelevant for this issue. That's just another subdirectory next to modules/themes/profiles, regardless of where they are located.

Consider me -1 on adding a top-level /contrib directory. Not everything is "contrib", most sites also have a couple of custom modules.

You will still be able to differ between contrib and custom stuff, if you want to, by simply putting them into respective subdirectories; e.g.:

/modules/contrib/*
/modules/custom/*

The discovery process does not care.

Let's keep this issue focused on sites/all/* » /*

webchick’s picture

I'd rather kick the idea of a "contrib" directory to some other issue. That's a brand new idea, whereas this issue is about reshuffling what we already have.

lpalgarvio’s picture

the whole "contrib" name wasn't referring to whether modules/themes/profiles are contrib, custom, fell_from_the_sky or belong to a category like administration, but rather, they are non-core, and also, are not specific to sites (ie, /sites/all).

it's rather a placeholder name. could be something else, like "global", "non-core", etc. what i'm trying to sell is just a top-level directory that holds /modules, /profiles, /themes, etc in it, keeping things a little more organized and separate.
i don't think they belong in /sites, but since we are changing and perfecting things, right now i don't feel comfortable with having them in /, for the various reasons mentioned above, and for others...

like i might add, it's also easier and faster to do a
tar -zcvf contrib.tar.gz contrib
than doing a
tar -zcvf contrib.tar.gz libraries modules profiles themes
or a
tar -zcvf contrib.tar.gz --exclude=core --exclude=sites --exclude=index.php --exclude=robots.txt --exclude=.htaccess --exclude=web.config .
from an administrator/backup point of view

the hierarchy inside these directories is another whole issue that i wasn't trying to discuss here; i've done it before elsewhere ;)

sun’s picture

I don't see why you'd want to tar all of your extensions without core. Your last command is factually wrong, because you still need to include /sites. In any case, if you want to do that, then you will have to care for excluding various stuff (or including the right stuff) either way.

Please, can we shift focus back to the actual proposal at hand?

The major benefit of having the directories at the top-level is that users are actually expecting them to be there. It improves the first-time user experience, because you do not have to step into various subdirectories in order to figure out where you should place the extensions you want to add. They're right there, KISS.

juan_g’s picture

sun wrote:

Can we move forward here?

If there are still concerns about removing support for sites/all/*, then I'd suggest to just simply not remove that discovery path from drupal_system_listing() - but still create the new top-level directories for freshly installed sites. In essence, we don't really care and if some people find sites/all/* more attractive than top-level directories for whatever reason in their custom setup, then they could happily use them.

If that's what it takes to get this patch in, then I will happily do that minimal adjustment/revert to the patch.

This seems a good, flexible compromise, so that site builders have more options to organize the file system the way they choose.

As suggested by others, other options like the recent proposal to group directories, could also be discussed and considered later in other issues for possible addition to drupal_system_listing.

webchick’s picture

Status: Needs review » Needs work

Ok, let's do that then. Can we get an updated patch?

sun’s picture

Status: Needs work » Needs review
FileSize
687 bytes
14.23 KB

Done so :)

klonos’s picture

I guess that once we have #1439316: Provide means for module maintainers to collect heuristics on certain settings of their modules. in place and enough time has passed so to have adequate data collected, we'll be able to see the percentage of people still using /sites/all. If that amount is trivial, then perhaps we can revisit this and remove the support for /sites/all/*. I guess we'll only want to do this for performance reasons - if that is an issue with that specific feature.

tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community

I used the previous patch on a site for 2 weeks, and the new one still works as well, and is LESS controversial.

webchick’s picture

Title: Replace /sites/all/* with top-level directories » Change notice: Replace /sites/all/* with top-level directories
Priority: Normal » Critical
Status: Reviewed & tested by the community » Active
Issue tags: +Needs change record

Ok great. I did a quick manual test to ensure that multisite was still working with this patch, and despite a derail based on my assumption that it picked up subdomains even though it does not... it still works. So yay!

Committed and pushed to 8.x. WOOHOO. This is going to need a change notice.

sun’s picture

Title: Change notice: Replace /sites/all/* with top-level directories » Change notice: Allow and encourage top-level directories instead of /sites/all/* directories

Slightly adjusting the issue title to avoid confusion. The committed patch did not, actually, "replace" /sites/all/*.

sun’s picture

Title: Change notice: Allow and encourage top-level directories instead of /sites/all/* directories » Allow and encourage top-level directories instead of /sites/all/* directories
Priority: Critical » Normal
Status: Active » Fixed
Issue tags: -Needs change record
plach’s picture

According to the last paragraph of the change notice:

In addition of making the directory structure much more intuitive for all users, this change also includes the separation of installation profiles provided by Drupal core in /core/profiles vs. contributed and custom installation profiles in /profiles, which helps with updating the code-base.

I think the D8 example is slightly misleading:

/core/modules        # Drupal core modules only. (!)
/core/themes         # Drupal core themes only. (!)
/core/profiles       # Drupal installation profiles. (mixed)

Should be something like:

/core/modules        # Drupal core modules only.
/core/themes         # Drupal core themes only.
/core/profiles       # Drupal core installation profiles only.
sun’s picture

Sorry, yeah, stupid copy/paste error. Fixed it. Thanks! :)

lpalgarvio’s picture

great =)

found an old related issue:
#1443420: About Drupal 8 directory structure

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

jwilson3’s picture

A question came up about this change on #1539940: Encourage best practices in /sites/README.txt, /modules/README.txt, /profiles/README.txt and /themes/README.txt.

Specifically, how does this affect the other sub-directories in sites/all that haven't been mentioned (such as translations, libraries, drush, etc).

moshe weitzman’s picture

great patch that i wish i was following at the time. i really think we should go all the way and remove sites/all from the discovery process. it does not simplify drupal to add new ways of doing stuff. you have to remove the old ones too. the only justification given here "so we can let site builders choose where to put their files". i think thats pretty weak relative to the added confusion of 'the modules could be here or there or there or ..."

i'm adding drush support for this patch and each directory scan takes time.

moshe weitzman’s picture

jhodgdon’s picture

Regarding #49, I did a bit more research...
- libraries are contrib-only so I think we shouldn't bother making a top-level directory for them.
- translations apparently don't belong in sites/all at all. See #1802322: Translation instructions are incomplete

rafamd’s picture

RE #50, true, too many more than one ways of doing the same thing confuses.

pounard’s picture

#50 And how about multisite? How will this work?

moshe weitzman’s picture

@pounard - the recommended place to put code thats shared across sites is now /modules, /themes, /profiles, etc. thats the whole point of this issue, which has been committed.

pounard’s picture

ho you mean that even multisite would share all, and there should be no way to provide different module versions on different sites? I never really used it except once, that's a very uncommon doing, but is that something we can do?

jhodgdon’s picture

pounard: read the change notice on this issue (link is up in the summary section) -- it should answer all of your questions. sites/(site) is still available, as is sites/all.

pounard’s picture

I was asking because #50 was suggesting i really think we should go all the way and remove sites/all from the discovery process and that's disturbing regarding multisite. Aside of that, I'm not against this issue, it's a fine feature to allow both top level instead of all and sites/SITE/*

Grayside’s picture

I read that as dropping sites/all, not dropping sites/{sitename}.

sites/all does allow for folks to easily create a standard recipe without going all the way into basic profile creation, but with tools like drush make I think that ground is reasonable well covered.

pounard’s picture

Oh my... ok I misunderstood what he said, sorry.

klonos’s picture

@jhodgdon, #52:

...libraries are contrib-only so I think we shouldn't bother making a top-level directory for them.

...well there's #667058: Add a libraries folder with a README.txt in it to DRUPAL_ROOT

jwilson3’s picture

Issue tags: +Libraries

Tagging, per #61.

jwilson3’s picture

Issue summary: View changes

Updated issue summary.