📚 Product Knowledge
Multisite Content
📖 Docs

Multisite Content - Optimizely CMS 12

Exam Area: Area 1 – Product Knowledge (15%) Reference: https://docs.developers.optimizely.com/content-management-system/docs/multi-site


1. What is Multi-Site?

CMS 12 supports running multiple websites from a single CMS installation. Each site has its own start page, URL bindings, and content tree.

Single CMS installation:
  ├── Site A: www.brandA.com (start page: /SiteA)
  ├── Site B: www.brandB.com (start page: /SiteB)
  └── Site C: internal.company.com (start page: /Internal)

2. Benefits of Multi-Site


3. Content Assets (Per-Site vs Global)

StoragePathScope
For All Sites/globalassetsShared across ALL sites
For This Site/contentassets (per start page)Scoped to one site only
// GlobalAssets root
ContentReference globalRoot = ContentReference.GlobalBlockFolder;

// Site-specific assets root (based on current start page)
ContentReference siteRoot = ContentReference.SiteBlockFolder;

4. Detecting the Current Site

// SiteDefinition.Current is the site matching the current HTTP request
var currentSite = SiteDefinition.Current;
var siteName    = currentSite.Name;
var startPage   = currentSite.StartPage;

// Check if a content item belongs to the current site
bool isOnCurrentSite = currentSite.StartPage == someContentRef.ToReferenceWithoutVersion() ||
    _contentLoader.GetAncestors(someContentRef)
        .Any(a => a.ContentLink == currentSite.StartPage);

5. Site-Specific Templates

// Use tags or route data to select different views per site
[TemplateDescriptor(Tags = new[] { "SiteA" })]
public class SiteAArticleController : PageController<ArticlePage>
{
    public IActionResult Index(ArticlePage page) => View("SiteA/ArticlePage", page);
}

[TemplateDescriptor(Tags = new[] { "SiteB" })]
public class SiteBArticleController : PageController<ArticlePage>
{
    public IActionResult Index(ArticlePage page) => View("SiteB/ArticlePage", page);
}

6. Sharing Blocks Between Sites

Blocks stored in /globalassets/ are visible to all sites.
Editors on Site A can use blocks from globalassets.
Editors on Site B can also use the same blocks.

7. Cross-Site Links

// IUrlResolver generates absolute URLs for cross-site links
var absoluteUrl = _urlResolver.GetUrl(
    contentRef,
    language: "en",
    new VirtualPathArguments { ForceAbsolute = true });
// Returns: https://www.brandB.com/some-page/

8. ISiteDefinitionRepository

// Get all sites
var allSites = _siteDefinitionRepository.List();

// Get a site by ID
var site = _siteDefinitionRepository.Get(siteGuid);

// Create a new site
_siteDefinitionRepository.Save(new SiteDefinition
{
    Name      = "Brand C",
    SiteUrl   = new Uri("https://www.brandc.com/"),
    StartPage = new ContentReference(200)
});

9. Admin UI: Sites

Admin → Websites
  → Add site → select start page, enter hostname(s)
  → Each site shows: name, URL, start page, language configuration

Review Questions

  1. How many databases does a multi-site CMS installation use? (One — all sites share the same database)
  2. What is the path for content shared across all sites? (/globalassets — ContentReference.GlobalBlockFolder)
  3. How do you get the current site in code? (SiteDefinition.Current)
  4. Can different sites in a multi-site setup have different language configurations? (Yes — each site manages its own language bindings)
  5. Which interface manages site definitions? (ISiteDefinitionRepository)