I created site A successfully in sitecore and has deployed to production, now I want to add another site B to the same sitecore instance. I am aware of how to do this, but I am not sure how I can separate the two sites' code (layouts, controls etc.) so that one is not truly dependent on other. Instead of combining both the sites in the same site A project in visual studio, I was wondering if I can create a new project for site B but still reuse sitecore files that are in site A's project? What I am trying to understand really is the best practices in architecting multisite solutions in sitecore. Any ideas? Note: site A and site B are totally different in every aspect except the fact that they need to run on same sitecore instance.
I recommend you separate each site's assets into folders on the file system:
/Website/
/Website/sites/
/Website/sites/SiteA (<-- specific to SiteA)
/Website/sites/SiteB (<-- specific to SiteA)
/Website/sites/Common (<-- shared across any sites)
In Sitecore, do the same for your presentation components.
- layouts
- SiteA
- SiteB
- Common
- Sublayouts
- SiteA
- SiteB
- Common
And the same for templates:
Templates
User Defined
SiteA
SiteB
Common
Separate out C# class libraries too so they're specific to each site and have a common project for hared code (e.g. utility code for any site, extension methods, helper classes, etc). Visual Studio solution:
- WebApp
- SiteALib (<- SiteA specific code)
- SiteBLib (<- SiteB specific code)
- CommonLib (<- reusable code for any site)
As for the sites in the content tree, separate them out too at the same level:
sitecore
content
SiteA (<-- root item for SiteA)
home (<-- start item for SiteA)
SiteB (<-- root item for SiteB)
home (<-- start item for SiteB)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With