Exam Area: Area 1 – Product Knowledge (15%) Reference: https://docs.developers.optimizely.com/content-management-system/docs/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)
| Storage | Path | Scope |
|---|---|---|
| For All Sites | /globalassets | Shared 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;
// 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);
// 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);
}
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.
// 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/
// 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)
});
Admin → Websites
→ Add site → select start page, enter hostname(s)
→ Each site shows: name, URL, start page, language configuration
/globalassets — ContentReference.GlobalBlockFolder)SiteDefinition.Current)