Sitecore xDB Cloud 2.0 – Configuration, Connection, and Troubleshooting

In earlier, blog posts we discussed the basics of xDB Cloud, some of the advantages and disadvantages of using xDB Cloud as well some useful terminologies. Now we will see how to configure xDB Cloud for various environments. Consider below versions of the resources for our exercise:

  • Sitecore Experience Platform 8.1 rev. 160519 (8.1 Update-3)
  • xDB Cloud 2.o
  • Sitecore xDB Cloud 8.1 rev. 160721

Configuration

  • Get xDB subscription by getting in touch with Sitecore. Make sure it is attached with your license id. If you make any change to your licensing than reassure it is still attached with the xDB Cloud. Consider the usage and requirement of business subscribe a number of xDB Cloud database set required.

  • Once you have subscribed for xDB Cloud, To request an xDB Cloud 2.0 customer set, You required below things:

    • Your License ID (11111111111111). Get it from the license file. Sitecore 8.1 now requires a license with the “Sitecore.xDB.base” key to enable all features of the Experience Platform. If your license file does not contain this key, Sitecore will default to Experience Management (CMS-only) mode. Any customers or partners with a license to Experience Platform should contact their account manager or login to SPN if they are missing this key.
    • Your Deployment Id (COMPANYPROD81). Get it based on a role of the instance like Dev, Stag, Prod etc. If you do not receive it from Sitecore support, get it using Rest API.
    • The version of Sitecore that you are running (8.1 rev. 160519).
    • The preferred location for your xDB Cloud environment. See the xDB Cloud Service compatibility tables for compatible data center locations. Though, you don’t required it to specify anywhere.
    • MongoDB connection strings:
      analytics, live, tracking.history, tracking.contact. If you do not receive it from Sitecore support, get it using Rest API.
    • A Search index connection string (applicable to Sitecore 8.2.1 and later): cloud.search.
    • Reporting service settings, including the address of the service and the thumbprint of the SSL certificate. If you do not receive it from Sitecore support, get it using Rest API.
  • Download xDB Cloud Client based on Sitecore version and xDB Cloud version. In our case, we needed to download Sitecore xDB Cloud 8.1 rev. 160721. Check https://kb.sitecore.net/articles/966080 for xDB Cloud Service compatibility tables.

  • Now, we need to Enable/Disable the config files as per the role we are configuring.

    • CM: Enable/Disable the files as described in https://doc.sitecore.net/sitecore_experience_platform/81/setting_up_and_maintaining/xdb/configuring_servers/configure_a_content_management_server and Config Enable Disable spreadsheet. Note: based on the version of Sitecore, this will be very.
    • CD: Enable/Disable the configs as described in https://doc.sitecore.net/sitecore_experience_platform/81/setting_up_and_maintaining/xdb/configuring_servers/configure_a_content_delivery_server and Config Enable Disable spreadsheet. Note: based on the version of Sitecore, this will be very.
    • CM + CD (Development): Ensure that the following configuration files are disabled or removed from your local installation by adding .disabled to the end of the file name.
      File path (relative to the website root) Configuration file name
      /App_Config/Include Sitecore.Analytics.Processing
      .Aggregation.Services.config
      /App_Config/Include Sitecore.Analytics.Processing
      .Services.config
      /App_Config/Include Sitecore.Analytics.Tracking
      .Database.ScaledCM.config
      /App_Config/Include Sitecore.MarketingProcessing
      Role.config
      /App_Config/Include Sitecore.PathAnalyzer
      .Processing.config
      /App_Config/Include/CES Sitecore.CES.DeviceDetection
      .CheckInitialization.config
      /App_Config/Include/ContentTesting Sitecore.ContentTesting
      .Processing.Aggregation.config
      /App_Config/Include/ExperienceAnalytics Sitecore.ExperienceAnalytics
      .Aggregation.config
      /App_Config/Include/ExperienceAnalytics Sitecore.ExperienceAnalytics
      .ReAggregation.config
      /App_Config/Include/ExperienceAnalytics Sitecore.ExperienceAnalytics
      .StorageProviders.config
      /App_Config/Include/ExperienceAnalytics Sitecore.ExperienceAnalytics
      .Reduce.config
  • Configure a content management server to use a remote Reporting Service Server as per https://doc.sitecore.net/sitecore_experience_platform/setting_up_and_maintaining/xdb/configuring_servers/configure_a_content_management_server_to_use_a_remote_reporting_service_server Specify ReportingServiceUrl given by Sitecore Support. If you do not receive it from Sitecore support, get it using Rest API.

  • For xDB Cloud 2.0, Update the Path Analyzer configurations. If you connect to a dedicated remote reporting instance, then the content management server no longer has direct access to the Sitecore.Analytics SQL Server reporting database. Instead, the Path Analyzer client retrieves data from a remote reporting server with direct access to the SQL database using Web API services. To enable the Path Analyzer client to communicate with the remote reporting server, make the following configuration file changes:

    Configuration file Folder Enable Disable
    Sitecore.PathAnalyzer
    .RemoteClient.config
    App_Config/Include Picture 154
    Sitecore.PathAnalyzer
    .Processing.config
    App_Config/Include Picture 155
    Sitecore.PathAnalyzer
    .Services.RemoteServer.config
    App_Config/Include Picture 156
  • In the XdbCloud folder (Website/App_Config/Include/xDBCloud), delete the following files. If they already have the extension.disabled it is a good idea to delete them at this point.

    • Sitecore.Cloud.Xdb.config
    • Sitecore.ContentSearch.Cloud.Index.Analytics.config
    • Sitecore.ContentSearch.Cloud.Default.IndexConfiguration.config

 

  • Use the Sitecore Installation Wizard to install the Sitecore xDB Cloud 8.1 rev. 160721 package.

  • To configure instance to communicate with dedicated Azure services of Sitecore xDB Cloud

    • In the fileConnectionStrings.config(Website/App_Config), configure the MongoDB database connection strings by using the connection strings from the response that you received from Sitecore Support. If you do not receive it from Sitecore support, get it using Rest API.The MongoDB connection strings:
      • analytics
      • tracking.live
      • tracking.history
      • tracking.contact

      Note: For a CD instance, you do not require the tracking.history connection string.

    • In the ConnectionStrings.config file (Website/App_Config), add the analytics.cloud.index Connectionstring. Which you generally do not find in ConnectionStrings.config
    • In the ConnectionStrings.config file (Website/App_Config), ensure the following connection string is removed:<add name="reporting" connectionString="Data Source=…"/>
    • In the Xdb Cloud folder (Website/App_Config/Include/xDBCloud), enable the following configuration file:
      • Sitecore.Cloud.Xdb.config

      For versions prior to 8.2 Update-1, also enable below config files:

      • Sitecore.ContentSearch.Cloud.DefaultIndexConfiguration.config
      • Sitecore.ContentSearch.Azure.Index.Analytics.config
        (There isn't such config file available. Enable below config file instead.)
        Sitecore.ContentSearch.Cloud.Index.Analytics.config
    • In the folder (Website/App_Config/Include/), disable the following configuration files:
      • Sitecore.ContentSearch.Lucene.Index.Analytics.config
      • Social\Sitecore.Social.Lucene.Index.Analytics.Facebook.config
    • In the Sitecore.Cloud.Xdb.config file (Website/App_Config/Include/Xdb Cloud), configure the reporting service by using the actual Service URL and SSL certificate thumbprint from the response that you received from Sitecore Support, for example:
      <httpTransportFactory patch:instead="httpTransportFactory" type="Sitecore.Cloud.Xdb.CloudBasedTransportFactory, Sitecore.Cloud.Xdb" singleInstance="true">
      <param desc="serviceUrl">[reporting service URL]</param>
      <param desc="certificateThumbprint">[SSL certificate thumbprint]</param>
      </httpTransportFactory>

      By setting this reporting service properly, you will able to see experience analytics reports working on your Sitecore instance. Still you need to confirm if analytics data are getting stored to MongoDB or not.

  • To complete the xDB Cloud client configuration and connection to the xDB Cloud service, you must deploy marketing definitions.

    • On the Sitecore Launchpad, click Control Panel, Analytics, Deploy marketing definitions.
    • In the Deploy marketing definitions dialog box, select all of the definitions and taxonomies and click Deploy.

Connection

After successfully configuring xDB Cloud for your website, you will be very eager to test it by connecting to MongoDB. But unfortunately there isn’t a straight forward of doing same as you cannot connect to xDB Cloud using Robomongo or MongoVUE tool.

These are the best possible ways doing same:

  • Using Rest API like
  • By generating some random traffic on the site, and by manually or technically doing Session Abandon to reflect the Contact details in Experience Profile.
  • Give a unique name to the site definition rather than website, and generate the random traffic to get the unique site name reflected in Analytics Reports when Session ends.
  • If none of the above trick work than there is maximum chance of connectivity issue, means your data is not getting saved to MongoDB. But still as last option, you can contact Sitecore Support and request full database set collections as backup. By examining the backup collections, you can confirm weather data is getting stored or not.

Troubleshooting

While configuring/connecting xDB Cloud, I ran into several issues. Below are some note on that if you face the same, can save your day by applying these tweaks:

  • While deploying Marketing Definitions to complete the configuration/setup, i was getting following error:
    MarketingDefinitions
    Kiran Patil – Maiden Indian Sitecore MVP, found following error in log file Could not find configuration node: marketingDefinitions/asset/repositories/remote.
    And with his analytical ability he was able to solve this by enabling following config file Sitecore.Xdb.Remote.Client.MarketingAssets.config in \Website\App_Config\Include\
  • While data was getting stored to xDB Cloud at one infrastructure without touching Firewall settings, at another infrastructure it was not getting saved by performing all same steps mentioned above. By checking log file I found error ERROR unable to connect to a member of the replica set matching the read preference primary.
    One of the thing i tried to get rid of this error is removing replica set and secondary servers from ConnectionString which didn’t solved the issue but ended up changing error to ERROR Unable to connect to server *.mongolab.com:[port]: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host..
    I ended up reverting the change. And looking into Firewall related settings. Will share my learning once i solve the issue.

 

Advertisements

Sitecore xDB Cloud 2.0 – Useful Terminologies

In earlier, blog post we discussed the basics of xDB Cloud, some of the advantages and disadvantages of using xDB Cloud. Now it’s time to jump on the battle field to configure the xDB Cloud on the local environment. But before moving ahead to configuration and connection, let’s walk through few terminologies which will help you understand each and every configuration very well throughout the setup.

  • The xDB Cloud Set – a set of cloud services and connected databases that implement on-premise xDB functionality off-premise in the cloud. This functionality includes the ability to collect and process experience data, as well as contact search and segmentation. In a simple word, It is the set of databases like analytics, tracking.live, tracking.history, tracking.contact, analytics.cloud.index which you generally found in your connectionstring.config.

  • LicenseId – It refers to the Id of your Sitecore license. It will be required while doing Rest API calls which you will see in future blog posts.

  • DeploymentId – Every xDB Cloud set assigned a DeploymentId. Id using which you identify the different set/role. For ex: If we have purchased two xDB Cloud set one for Stag and one for Prod than we will have to correspond DeploymentId. For ex: XYZSTAG01, XYZPROD01. This will be very helpful along with LicenseId while making Rest API call for various purposes.

  • DeploymentType – Type of the xDB Cloud set, either Prod or Non-Prod.  Generally, you don’t need to specify the Deployment Type anywhere. Prod type won’t have reporting related to dataset.

  • SitecoreVersion – The Sitecore version, on which a site is running. There will be little change in configuration based on Sitecore version. We will consider Sitecore Experience Platform 8.1 rev. 160519 (8.1 Update-3) for rest of the blog series.

  • XdbCloudVersion – Version of the Xdb Cloud. Xdb Cloud 1.0/2.0 are available. Based on which Cloud set you have, it requires different configuration.

  • xDB Cloud Client – A package responsible for copying required xDB Cloud DLLs and Config files when installing. It will be different based on Sitecore Version and XdbCloudVersion.

  • XdbConnectionStrings – Connectionstring for all analytics databases like analytics, tracking.contact, tracking.history, tracking.live, analytics.cloud.index etc.

  • ReportingServiceUri – You cannot access reporting SQL database directly in Cloud. You have to access it using a service. So, service for reporting called ReportingServiceUri needed to be updated in one of the config files for xDB Cloud.

  • ReportingServiceCertificate – It is a certificate id provided by Sitecore Support or Rest API, which is required to securely talk with reporting service. It also needed to update in config along with ServiceUri.

Knowing these terms will give you a better understanding of overall xDB Cloud set. And you are now eligible for the configuration and connection which will take place in next blog post.

Go Cloud 🙂

featured-enterprise-cloud-strategy-eBook

Sitecore xDB Cloud 2.0 – What it is? Advantages and disadvantages over On-Premise setup

Sitecore and Cloud

Sitecore extensively looking to offer the cloud offering after joining the party with Microsoft in 2016. In an effort to that, Sitecore now available as an App Service on Azure. Have a look at it https://azuremarketplace.microsoft.com/en-us/marketplace/apps/Microsoft.AppSvc_SiteCore_xp?tab=Overview/ Along with this, Sitecore also supports xDB service completely on the cloud (xDB Cloud) if you are running Sitecore 8.0 or higher.

What is included in Sitecore xDB Cloud?

Sitecore xDB Cloud Edition is a managed service that enables you to run Sitecore xDB entirely in the Cloud. This service includes dedicated Sitecore application servers for processing, aggregation, and reporting.

  • Microsoft SQL Server reporting database
  • MongoDB collection database
  • Contact segmentation index

xDB Cloud overview-Picture 1-rId10-1173281914

That means, When using xDB Cloud offerings, you do not need to take care of reporting, aggregation, and processing server. Your CM and CD environments will be limited to their job of serving site only rather than acting as processing server too which will make them healthy.

Why it is important?

The Sitecore xDB Cloud service provides the following benefits over an on-premise installation:

  • A simpler infrastructure
  • Reduced upfront costs
  • Reduced maintenance costs
  • Increased reliability, provided by the Microsoft Azure cloud platform and the MongoLab (mlab) service for MongoDB databases.
  • A fully managed service that includes Sitecore updates and monitoring. Sitecore continuously monitors the xDB Cloud Sets to minimize system downtime.

Also refer to the fine blog post, which helps you define what solution fits your requirements, either on-premise or on the cloud.

xDB_DecisionTree
Source: http://www.nonlinearcreations.com/Digital/how-we-think/articles/2015/07/Sitecore-xDB-to-Cloud-or-not-to-Cloud.aspx

Let’s also understand some of the things which are not supported by xDB cloud:

  • The downside is that you don’t have direct access to the various collections. So, you can’t connect using a tool like Robomongo or MongoVUE. However, you can request a full export of the xDB Collection database through support.sitecore.net
  • It’s important to note that the reporting SQL databases are hosted in the cloud. This includes both the primary and secondary. There is currently no way to successfully rebuild the reporting databases from the /sitecore/admin/rebuildreportingdb.aspx page. It looks like we have a Rest API for this purpose.
  • You cannot add custom facets to contacts.
  • You cannot create reports based on custom aggregations.
  • You cannot create custom database and collections, hence you have to opt for stand alone database set for different purpose (For ex: Development, QA, Stag, Prod etc.).
  • For more information on what is possible and what not, refer: https://kb.sitecore.net/articles/042722/

Though there are several limitations using xDB Cloud listed above still it’s winning the game. While Sitecore continued to expand its wings on the cloud with the help of Azure, Sitecore is saying that it’s just a beginning and you can expect a lot of things in that direction.

We will see what are the prerequisite and how to configure it for local, CM, and CD in upcoming blog posts.

Setting up Habitat without having Visual Studio installed on server

Have you started checking Habitat architecture? If no, this is the best time to get started as Sitecore is evolving faster than it used to and customers are also asking competitive and best enterprise solutions. In this case sometime it becomes difficult to manage your project architecture specially in a big project/team. So, why not look at Habitat? an example provided by Sitecore as a best practice for Sitecore projects based on Helix architecture.

There are many resources available on how to setup Habitat for sitecore correctly like
https://github.com/Sitecore/Habitat (source code)
https://github.com/Sitecore/Habitat/wiki/01-Getting-Started (Geting started guide)
https://www.youtube.com/watch?v=FNqKZN9DH5I (step by step video tutorial on how to setup Habitat for Sitecore)

I ran into a situation where i needed to setup a Habitat on a plain server where i won’t find IIS, Visual Studio etc. installed.

So, lets get on a tour on setting up Habitat without VS installed, Issues which we might face and solutions.

  1. Install plain Sitecore: first step first. Install a plain Sitecore 8.2 Update 1 on which we will setup Habitat. We will use this later
  2. Clone/Download Habitat project: Clone the Habitat repository or download zip from https://github.com/Sitecore/Habitat.
  3. Node.Js: Install latest Node.Js from https://nodejs.org/en/
  4. Perform all the steps specified in https://github.com/Sitecore/Habitat/wiki/01-Getting-Started until step 5. Or you can follow the video tutorial https://www.youtube.com/watch?v=FNqKZN9DH5I
  5. Now, we have arrived at the step to build and publish the solution to the Habitat Sitecore website we installed in the beginning.
  6. Without having Visual Studio installed, we cannot use Task Runner Explorer of VS. So, we have to use command window to run gulp command.

Now, you will start encountering the issues when trying to run gulp commands using command prompt. Some of issues and solutions are mentioned below:

  1. Go to the project directory where you have cloned the habitat project or downloaded and unzipped a project.
  2. Run npm gulp command in that directory on to command window.
  3. Now, if you have not installed all the required modules properly from npm and try to execute gulp task like gulp default, then it will start giving error. In my case it was cannot find module gulp-msbuild. so rather running npm gulp command in project directory, run npm install command so that it will install all the required plugins along with gulp.
  4. I tried to run the default task specified in gulpfile.js using gulp default command. And i got the error saying gulp is not recognized as internal or external command. You required gulp-cli package to be installed to run gulp command from command window. So, if it is missing and you are facing this issue than run npm install -g gulp-cli command. Now once you have installed this package you can run the gulp command as gulp default from the command window.
  5. Running gulp default command again, You may face error saying Nuget package installation failed. As VS is not installed, Nuget will not be installed by default.So, you have to install Nuget command line from https://dist.nuget.org/win-x86-commandline/latest/nuget.exe or https://docs.nuget.org/consume/command-line-reference/.
  6. Running gulp default command again, Nuget package installation will get complete but you may face error saying Build Failed. As VS is not installed on server. So, you will required to install MSBuild tool. You can find it here: https://www.microsoft.com/en-in/download/details.aspx?id=48159
  7. Running gulp default command again, i got error saying MSBuild – microsoft.webapplication.targets was not found issue even though we have installed MSBuild tool on the server. To resolve this, i just copied C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications folder from local to the server and tried run command again.
  8. Encountered error stdout maxbuffer exceeded, error in build gulp task.
    So, i come to know that there must be something tricky with MSBuild. It is missing something that generally shifts with VS in our local machine. I found a solution as per: http://nickberardi.com/a-net-build-server-without-visual-studio. We need to perform third step from the link, which says copy both the below folders from your local machine to server:

    • C:\Program Files (x86)\MSBuild
    • C:\Program Files (x86)\Reference Assemblies

    Between those two directories MSBuild and Reference Assemblies you have most everything you need to complete any build that Visual Studio can do by it self. And the above steps while simple, but not obvious, provide a nice clean build server that doesn’t require Visual Studio to operate.

Keep reading Helixian.

 

 

 

Disappearing cores in Solr after restart

You are setting up Solr cores, and it is getting disappeared on restart. Is this happening with you? Yes, It did happen to me as well when i got a chance to setup Solr for one of the Sitecore project.

I installed Solr 6.2 and completed all the installation and configuring steps. Than i started to create multiple cores for multiple indexes (Sitecore indexex like master/web/core/analytics etc.).

I created first core by copying the folder “configsets\basic_configs\conf” as per instructions and renamed it to relevant index say “sitecore_master_index”. I created a core for it in Solr using Solr admin UI. Everything works fine (even after restart 🙂). Than i started to create multiple cores for other indexes (core/web/analytics) by copying “sitecore_master_index” folder. I was able to create cores and it was working fine. When i came to office next day than i realized that cores are not showing in Solr admin UI.

What is the solution?

I tried many options to persist my cores, yes i also tried to add property persistent=”true” to <solr> node in Solr.xml, but no luck there too.

Than after fighting a lot, in logging tab i saw an error mentioning that Multiple cores found with the name “sitecore_master_index” while discovering cores. Here is an interesting fact about how Solr finds the core: “In older versions of Solr, cores had to be predefined as <core> tags in solr.xml in order for Solr to know about them. Now, however, Solr supports automatic discovery of cores and they no longer need to be explicitly defined. The recommended way is to dynamically create cores/collections using the APIs.”

As i got to know that issue is there with the name of cores, i checked the “core.properties” file inside other core folders like sitecore_core_index, sitecore_web_index, sitecore_analytics_index etc. and i found that name property having same value as sitecore_master_index as shown in below image:

solr1

Which was causing the issue while discovering cores. Giving unique core names solved the all issues and cores getting persisted after restart without specifying persistent=”true” property in Solr.config.

Please also specify if you faced similar situation and solved the issue in a different way, will be interesting to hear that.

Preview Publishing Target – Enable Normal View For Non-Sitecore Users

Enabling normal view to non Sitecore users to review changes before publishing the actual changes to production site – preview publishing target

Sometimes, we got requirements from client that some of their executives will also required to review the site changes before publishing it to live site, and upon that those executives will be non Sitecore users. In this case we need to enable normal view mode for non Sitecore users so that they can review changes before reaching to final state of workflow to publish to public site.

Sitecore has introduced a feature called Preview Publishing Target which allows us to publish the items to that specific target ignoring in which state of workflow an item is.

Let’s create a Preview Publishing Target and enable normal view for the non Sitecore reviewers step by step:

  • Create a copy database of web. We have named it here preview_web.
  • Add connectionstring in App_Config/Connectionstrings.config with above specified name preview_web.
  • Add database node in App_Config/Sitecore.Config <databases> pointing to above database preview_web.
  • Add new publishing target to /sitecore/system/Publishing targets/
  • 1
  • Check Preview publishing target check-box as shown in above image
  • Publish this item to both the target web and preview_web.
  • Go to workflow used in your site -> select state -> select the preview publishing targets from the list as shown below:
  • 2
  • Do the same steps for all the necessary workflow states.
  • Publish the workflow with subitems.
  • Now accessing item which is using above workflow, you can see the note as shown below:
  • 3
  • Now add a new site in site definitions in ~/App_Config/Sitecore.Config
  • <site name="previewsite" hostName="scpreview" enableAnalytics="true" enableTracking="true" virtualFolder="/" physicalFolder="/" rootPath="/sitecore/content" startItem="/homepage" database="preview_web" domain="extranet" allowDebug="true" cacheHtml="true" htmlCacheSize="50MB" registryCacheSize="0" viewStateCacheSize="0" xslCacheSize="25MB" filteredItemsCacheSize="10MB" enablePreview="true" enableWebEdit="true" enableDebugger="true" disableClientData="false" cacheRenderingParameters="true" renderingParametersCacheSize="10MB" />
    
  • Add bindings and host entry for above demo host
  • Now, make changes, publish changes to both web and preview_web instances before submitting or approving in final workflow state, changes will be visible in the above preview site. While live site will remain unchanged.

Note:

Hope this will help you in implementing similar scenario.

Using Display Name and Generating links for multilingual sites – Sitecore

About Display Name:

As many of us already aware, Display Name is used

In case of multilingual sites, where we required to generate links for pages specific to the language it is serving. For ex: there is a page in website named about-us and website is available in two languages English, and German. Now URL should be formed according to language as shown below:

This can be achieved by the feature referred as Display Name in Sitecore.

How to Assign Display Name

  • Create an item in Sitecore with the preferred name, in our example it is about-us.
  • For English language version display name will be same as item name so we will skip this part for English language.
  • For German language, Select the German language version of an item, click on Home (tab) -> Rename (chunk) -> Display Name command from the ribbon bar in content editor (You can also assign Display Name from Experience Editor).
  • A popup will appear expecting a text, enter the display name specific to the language which will then be used to form language specific URL. In our example equivalent to contact-us will be kontaktiere-uns, so enter this in textbox and save.
  • That’s it from the configuration part. You will see entered display name in content tree now instead of item name.

Generating Links While Using Display Name Feature

To generate URL specific to language using Display Name, You need to add useDisplayName=”true” into linkmanager in the sitecore.config. See below:


<linkManager defaultProvider="sitecore">
    <providers>
      <clear/>
      <add name="sitecore" type="Sitecore.Links.LinkProvider, Sitecore.Kernel" addAspxExtension="false" alwaysIncludeServerUrl="false" encodeNames="true" languageEmbedding="always" languageLocation="querystring" lowercaseUrls="true" shortenUrls="true" useDisplayName="true"/>
    </providers>
</linkManager>

After enabling Display Name in link manager, you can now generate link using link manager as follow:

Consider context language as English, and we need to generate link for German language version of item using display name. We can do it simply using link manager in view as:


@{

Sitecore.Links.UrlOptions options = new Sitecore.Links.UrlOptions();
options.Language = Sitecore.Data.Managers.LanguageManager.GetLanguage("de-DE");
options.LanguageEmbedding = Sitecore.Links.LanguageEmbedding.Always;
options.LanguageLocation = Sitecore.Links.LanguageLocation.QueryString;
options.UseDisplayName = true;

string URL = Sitecore.Links.LinkManager.GetItemUrl(Sitecore.Context.Item, options);

}

Will this generate the link we desire for German (de-DE) language? No.

The link generated using the above code will look something like http://[hostname]/about-us?sc_lang=de-DE

Why we are showing about-us in the URL instead of the kontaktiere-uns even though we have supplied language de-DE in UrlOptions.

After drilling down to Linkmanager code, come to know that language passed into UrlOptions not getting used while getting Display Name, It is getting Display Name of the item provided as first parameter of GetItemUrl()

In our case we are passing context item, and context language is English. As we do not have provided any Display Name for this item in English language, it will use Item Name itself to generate the URL.

So, we need to get the item in specific language before passing to GetItemUrl() function to form valid URL specific to language with help of Display Name. See below:


@{

string URL = Sitecore.Links.LinkManager.GetItemUrl(Sitecore.Context.Item, options);

}

In place of above line use below code:


@{

string URL = @Sitecore.Links.LinkManager.GetItemUrl(Sitecore.Context.Database.GetItem(Sitecore.Context.Item.ID, Sitecore.Data.Managers.LanguageManager.GetLanguage("de-DE")), options);

}

So, above code will first get German version of the about-us item, and thus will form a valid URL using Display Name provided for German language.