Search code examples
sitecoremultisite

Multi Regional and Language sites Sitecore


I'm using Sitecore and I'm wanting to make my site multi-regional and multi-lingual.

I want the url to be in the following format:

http://www.example.com/ca/fr (region then language)

http://www.example.com/ca/en

I currently have this in my config:

 <site patch:before="site[@name='website']" 
  name="Canada" enableTracking="true" 
  virtualFolder="/ca" physicalFolder="/ca" 
  language="en-gb" 
  rootPath="/sitecore/content/CanadaSite" 
  startItem="/home" database="master" 
  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" />

I have one complication in my project in the moment, the us version of English is also installed, but I always want the path to be /en. I don't think it's being used for any content.

Gemma


Solution

  • The default sitecore implementation for URL of a multilingual site is http:////

    In your case, if you are setting the virtualFolder as /ca, then your URL would be http://www.example.com/fr/ca

    http://www.example.com/en/ca

    instead of the desired /ca/fr and /ca/en

    Also the default sitecore behavior is to display in the url. For ex: fr-ca. However, it is easy to write a custom link resolver so that instead of /fr-ca, the custom link resolver will output /fr. But your original issue of language preceding the virtual folder name will not be addressed.

    I do not recommend you to change the custom link resolver to output language after the virtualFolder name. I have not attempted such a customization and do not know what pitfalls you may encounter, need to make sure that preview, experience editor etc all work with such a customization.

    The only other thing that you can look into is creating completely different sitenodes in the content tree and then you will need a corresponding site definition to point to that site node. In this approach the virtual folder in the site definition will be "/ca/en", "/ca/fr" and so on as shown below

      site patch:before="site[@name='website']" 
      name="CanadaFrench"
      language="fr-ca" 
      virtualFolder="/ca/fr" 
      physicalFolder="/ca/fr"    
      rootPath="/sitecore/content/CanadaFrenchSite" 
    
      site patch:before="site[@name='website']" 
      name="CanadaEnglish"
      language="en-us" 
      virtualFolder="/ca/en" 
      physicalFolder="/ca/en"    
      rootPath="/sitecore/content/CanadaEnglishSite" 
    

    This approach will work, you just need to configure each of your site to languageEmbedding="never". However, i would not recommend this approach as well, because we are completely bypassing sitecore's language versioning - in this approach you are just creating new site node for each language.