Let have example structure:

enter image description here

Normally when there is no SXA tenants exist and New Sample Item is published, LinkBuilder.GetItemUrl() will return something like


The problem is when SXA tenants are there. Then link should be created referring to it.

In short, I'm getting URL something like above which returns 404 when I try to use it. To make it work link has to be https://sc93sc.dev.local/en/New-Sample-Item, so relative to tenant root, not Sitecore root.

Is there a way to get that without custom LinkProvider?


var siteName = "website";
var site = SiteContext.GetSite(siteName);
var options = new UrlOptions
                AlwaysIncludeServerUrl = true,
                Site = GetSiteForPreviewLink(),
                Language = Language.Parse(language.Name)

var builder = new LinkProvider.LinkBuilder(options);
link = builder.GetItemUrl(sitecoreItem);
  • Are you using LinkProvider for Item URL? if yes, did you try by using LinkManager.GetItemUrl instead of it? Mar 27, 2020 at 13:17
  • yes, and it giving the wrong result too "/sitecore/content/New-tenant/New-site/Home/New-Sample-Item".
    – sc guest
    Mar 27, 2020 at 13:36
  • Is sc93sc.dev.local added as a valid URL to the Site Grouping of New Site?
    – Richard Seal
    Mar 27, 2020 at 14:35
  • yes. It is an example of my local instance. Seems is is added by setting "AlwaysIncludeServerUrl = true"
    – sc guest
    Mar 27, 2020 at 14:54
  • What is the GetSiteForPreviewLink doing in your code?
    – Gatogordo
    Mar 27, 2020 at 16:04

1 Answer 1


Mistery solved. Kinda. To make sitecore root relative URLs work I needed to change value of Virtual Folder field in Settings of my "New site" from default "/" to some "/whatever". 🤷‍♂️

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.