Sitecore Experience Accelerator

Add and select a custom link provider

Abstract

How to add and select different providers for different sites.

With SXA, you can select a different link provider for different sites. This can be useful when you have multiple sites that all have different link requirements. For example, if you want the language in the URL on multilingual sites and not on a single language site. To work with a custom link provider, you can add providers to the linkManager config section.

To add and select a link provider:

  1. Create a new patch file. Make sure to add your own <add/> node to the providers node under the linkManager node and add the code for your custom provider. For example:

    <linkManager defaultProvider="sitecore">
    <providers>
    <add name="customLinkProvider" type="Sitecore.XA.Foundation.Multisite.LinkManagers.LocalizableLinkProvider, Sitecore.XA.Foundation.Multisite" cacheExpiration="5" addAspxExtension="false" alwaysIncludeServerUrl="false" encodeNames="true" languageEmbedding="always" languageLocation="filePath" shortenUrls="true" useDisplayName="false"/>
    </providers>
    </linkManager>
    
  2. In the Content Editor, navigate to sitecore/content/tenant/site/settings/Site Grouping/site and in the Basic section, in the Link Provider name field, enter the name of your custom provider.

    BF2A3757B4AB43B192A2D0A8763EBB86.png