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">
<providers>
<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" />
</providers>
</linkManager>
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.
LinkProvider
insitecore.config
file. There islanguageEmbedding
. Set it to true;