After configuring the sitecore Habitat based on the instruction from GIThub, we could see sometimes locale code is getting added and not added to the URL.

This is happening inconsistently.But the content are loading as expected.

Both below URL are working fine



The same is happening EN and DA locale. Is there a way to show the locale code permanently in the URL

  • Find LinkProvider in sitecore.config file. There is languageEmbedding. Set it to true; – Marek Musielak May 26 '17 at 11:40
  • Yes. This works – PVM May 26 '17 at 17:13

This is controlled by the languageEmbedding attribute on your linkManager.

By default, Sitecore adds the language code to your URLs asNeeded. Which is a bit fuzzy; but essentially Sitecore should add it when it isn't sure of your current Context.Language and wants to make sure the URL points to the desired result.

Other options are:

  • Always (always enforce language in the url, this is what you ask for)
  • Never

You can find the configuration in your Sitecore.Config located under App_Include.

  <!-- Options (first is default):
           addAspxExtension: false | true (If you set this to false, remember to configure IIS to map all requests (*) to ASP.NET)
           alwaysIncludeServerUrl: false | true
           encodeNames: true | false
           languageEmbedding: asNeeded | always | never
           languageLocation: filePath | queryString
           lowercaseUrls: true | false
           shortenUrls: true | false
           useDisplayName: false | true
  <linkManager defaultProvider="sitecore">
      <clear />
      <add name="sitecore" type="Sitecore.Links.LinkProvider, Sitecore.Kernel" addAspxExtension="false" alwaysIncludeServerUrl="false" encodeNames="true" languageEmbedding="asNeeded" languageLocation="filePath" lowercaseUrls="false" shortenUrls="true" useDisplayName="false" />

It is not recommended practice to modify this file directly however. I recommend you implement any changes as a Sitecore Config Patch file. Described many places, for instance in Create a Sitecore LinkProvider to use different LinkManager.

| improve this answer | |
  • yes. this works – PVM May 26 '17 at 17:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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