We have upgraded to Sitecore 10.1 from Sitecore 8.7.

In Sitecore 8.7 We used MultisiteItemLinkProvider which derives from LinkProvider and its obsolete in Sitecore 10.1.

In Sitecore 8.7 we use the following code in the answer. Here is the link

public class MultisiteItemLinkProvider : LinkProvider 

Which we upgraded to Sitecore 10.1 like this

public class MultisiteItemLinkProvider : ItemUrlBuilder
        public MultisiteItemLinkProvider(DefaultItemUrlBuilderOptions defaultOptions) : base(defaultOptions)

        public override string Build(Item item, ItemUrlBuilderOptions options)
            if (Sitecore.Context.Site == null || Sitecore.Context.Site.Name == "shell")
                return base.Build(item, options);
            return GetItemUrlFromBase(item, options);

        protected virtual bool IsFromCurrentSite(Item item)
            Assert.ArgumentNotNull(item, "item");
            return item.Paths.FullPath.Contains(Sitecore.Context.Site.RootPath);

        protected virtual string GetItemUrlFromBase(Item item, ItemUrlBuilderOptions options)
            if (IsFromCurrentSite(item)) return base.Build(item, options);

            var website = this.GetSiteContext(item);
            using (new SiteContextSwitcher(website))
                options.AlwaysIncludeServerUrl = true;
                options.SiteResolving = true;
                return base.Build(item, options);

        private static List<KeyValuePair<string, Sitecore.Sites.SiteContext>> GetSites()
            return SiteManager.GetSites()
                    s =>
                        !string.IsNullOrEmpty(s.Properties["rootPath"]) &&
                    d => new KeyValuePair<string, Sitecore.Sites.SiteContext>($"{d.Properties["rootPath"]}{d.Properties["startItem"]}",
                        new Sitecore.Sites.SiteContext(new SiteInfo(d.Properties))))

        public virtual Sitecore.Sites.SiteContext GetSiteContext(Item item)

            var site = GetSites().LastOrDefault(s => item.Paths.FullPath.ToLower().StartsWith(s.Key.ToLower()));
            return site.Value;

in the config

    <itemUrlBuilder type="Sitecore.Links.UrlBuilders.ItemUrlBuilder, Sitecore.Kernel">
        <patch:delete />

    <itemUrlBuilder type="Foundation.Multisite.Providers.MultisiteItemLinkProvider, Foundation.Multisite">
        <param desc="defaultOptions" type="Sitecore.Links.UrlBuilders.DefaultItemUrlBuilderOptions, Sitecore.Kernel">


In Sitecore 8.7 we are calling the method like this

LinkProvider multisiteItemLinkProvider = LinkManager.Providers["MultisiteItemLinkProvider"];

How can we call let's say MultisiteItemLinkProvider's GetItemUrl method in Sitecore 10.1?

  • Why did you inherit from ItemUrlBuilder? Should it not still be LinkProvider? The part that is obsolete is the constructor, not the class. Apr 19, 2023 at 1:56
  • @MichaelWest I tried to use the existing LinkProvider code and it was working fine. The only issue I had was some of the auth sites were appending the prod site when clicking the search URL like "test1-sc10-auth.comhttps//test1-sc10.com/…". When I replaced the LinkProvider method with the ItemUrlBuilder then that issue was gone. Apr 19, 2023 at 2:02

3 Answers 3


As you have prepared a custom item URL builder. You can inject a custom URL builder by patching the <links/itemUrlBuilder> configuration node.

<?xml version="1.0"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">

                <patch:attribute name="type">YourProjectNamespace.MultisiteItemLinkProvider, YourProjectNamespace</patch:attribute>

Also, worth to look these solutions.

  1. Create a foundation UrlBuilder with custom pipeline
  2. Extend from LocalizableLinkProvider If you are using SXA. The default LocalizableLinkProvider is actually allow us to extend but have to override GetItemUrl(Item, ItemUrlBuilderOptions) instead.

Credit: Multi custom links with Sitecore 10 using ItemUrlBuilder

Hope it helps!

  • Thanks Sumit but I have already included this in the config. I want to know how can I call let's say GetItemUrl method in the code. I have also updated my question that this config already exists. Apr 19, 2023 at 3:20

Not sure if it will work for you but you can try your custom Link provider using this way.

var customProvider = ServiceLocator.GetRequiredResetableService<ProviderHelper<Sitecore.Links.LinkProvider, LinkProviderCollection>>()?.Value?.Provider as YourNamespace.LinkProvider;

Try to use this and see if you are able to achieve what you need.

Ref: How to call custom LinkProvider


I found this tutorial elsewhere, it worked for me: https://edwenkerk.hashnode.dev/multi-custom-links-with-sitecore-10-using-itemurlbuilder

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.