Search code examples
sitecoresitecore7

sitecore multi site set up in visual studio 2012


I want to set multi site setup in Visual studio for multiple sites in Sitecore. I want to have separate Layouts/sublayouts/ascx and code behind for all websites. Also i want separate config files for each website so that it will be easy to update individual sites. i didn't find any appropriate documentation from web.

Any help


Solution

  • This is what I do as far as Sitecore and Visual Studio structure goes:

    1) Create sub folders for your sites in Sitecore within the Content, Layouts, Templates and Media Library folders.

    enter image description here

    2) Create sub folders in your web root on disk. Do this for the Layouts/View folder, but also for the client-side includes (css/js).
    So you will get a structure like this:

    enter image description here

    3) Create a separate web application project for each site and place the .csproj file inside the web root.
    Then include the necessary folders per project (so the Include/Site1, Views/Site1 folder are included in the project for Site1, etc).

    enter image description here

    4) Configuration is a little tricky, because you will always share one Sitecore configuration with all the site instances.
    But what I do for settings is prefix them with the site name, like this:

    <setting name="Site1.MySetting" value="MyValue" />
    

    You can then put that in separate config files in the /App_Config/Include folder.
    That will give you at least some separation of configuration per site.

    I would create at least one sub folder within the Include folder to ensure your custom configuration is included as last.

    5) I will usually also add one "site" project called Global that contains everything that is shared between the instances.
    That will mainly contain templates in Sitecore and in the VS project it contains references to /sitecore files, global.asax, web.config and App_Config files.

    There are of course many more factors to account for, but these are the basics for setting up the solution.