Thursday 27 February 2014

How to add a new publishing target in Sitecore

Leave a Comment
In this blog post, I am going to explain how to add a new publishing target in Sitecore.  Basically publishing target comprises of a target database (where the content will be published) and publishing target definition item in master database that points to that target database. We create target database entry in ConnectionStrings.config file and specify publishing target definition item in content tree at path /sitecore/system/Publishing targets.

Creating a new publishing target is very helpful if your Sitecore environment is setup in multiple content delivery servers. We can publish data from Master database to one or more publishing target databases. Main thing to notice here is Master database contains all versions of any content or assets while publishing target database contains single latest version for each language.

Below are the steps to add a new publishing target in Sitecore:
  • Create target database (where the content will be published) entry in ConnectionString.config 
    <add name="preprod" connectionString="user id=sa;password=sa;Data Source=.;Database=Sitecore_PreProdDatabase"/>
  • Open web.config and search for <databases> node.
  • Copy and paste any existing <database> node and change the database id with the connection string name.
      <!-- preprod-->
          <database id="preprod" singleInstance="true" type="Sitecore.Data.Database, Sitecore.Kernel">
            <param desc="name">$(id)</param>
            <connectionStringName>$(id)</connectionStringName>
            <icon>Software/16x16/application_server.png</icon>
            <dataProviders hint="list:AddDataProvider">
              <dataProvider ref="dataProviders/main" param1="$(id)">
                <prefetch hint="raw:AddPrefetch">
                  <sc.include file="/App_Config/Prefetch/Common.config"/>
                  <sc.include file="/App_Config/Prefetch/Core.config"/>
                </prefetch>
              </dataProvider>
            </dataProviders>
            <workflowProvider hint="defer" type="Sitecore.Workflows.Simple.WorkflowProvider, Sitecore.Kernel">
              <param desc="database">$(id)</param>
              <param desc="history store" ref="workflowHistoryStores/main" param1="$(id)"/>
            </workflowProvider>
            <archives hint="raw:AddArchive">
              <archive name="archive"/>
              <archive name="recyclebin"/>
            </archives>
            <cacheSizes hint="setting">
              <data>20MB</data>
              <items>10MB</items>
              <paths>500KB</paths>
              <itempaths>10MB</itempaths>
              <standardValues>500KB</standardValues>
            </cacheSizes>
            <Engines.HistoryEngine.Storage>
              <obj type="Sitecore.Data.$(database).$(database)HistoryStorage, Sitecore.Kernel">
                <param connectionStringName="$(id)">
                </param>
              </obj>
            </Engines.HistoryEngine.Storage>
            <NotificationProvider type="Sitecore.Data.DataProviders.$(database).$(database)NotificationProvider, Sitecore.Kernel">
              <param connectionStringName="$(id)">
              </param>
              <param desc="databaseName">$(id)</param>
            </NotificationProvider>
          </database>
    
  • Add publishing target definition item in master database.  Navigate to /sitecore/system/Publishing targets. Right click and add insert new publishing target.
  •  Give any significant name to publishing target definition item.  Enter database id in the Target database Field. 
  • Open Sitecore publishing dialog and you can see newly created publishing target.
Comments and suggestions are most welcome. Happy coding!   
Read More...

Thursday 13 February 2014

Disable Language Code embedding in URLs in Sitecore

Leave a Comment
By default, Sitecore organize and classify contents based on the language. A page can be accessed by using several URLs in Sitecore. Below URLs are pointing to same page:

http://www.mydemowebsite.com/en/home.aspx
http://www.mydemowebsite.com/home.aspx 

You can observe that sometimes language code get embedded in the page URL.

For example:
http://www.mydemowebsite.com/en/home.aspx

Notice language code “en” (english) in the URL. If you look at the content tree in Sitecore, you won’t find any “en” node in content tree. Instance of such URLs are mainly seen in multi-site environment and may be affect adversely on SEO. Language code embedded URLs can also confuse various statistical and analytics tool like Google Analytics or Adobe Omniture Site Catalyst. Analytics data is collected per URL basis from javascripts inserted on the page. Analytics tools consider them as separate URLs (for example: URL without en and URL with en will be considered as two different pages). Thus it will be difficult to get total number of hits on particular page content.  

You can disable language code embedding by modifying linkManager provider settings in web.config. You can find below default settings in web.config:
<linkManager defaultProvider="sitecore">
  <providers>
    <clear />
    <add name="sitecore" type="Sitecore.Links.LinkProvider, Sitecore.Kernel"
         addAspxExtension="true"
         alwaysIncludeServerUrl="false"
         encodeNames="true"
         languageEmbedding="asNeeded"
         languageLocation="filePath"
         shortenUrls="true"
         useDisplayName="false" />
  </providers>
</linkManager>
The inclusion of language code in URL depends on below setting:
languageEmbedding="asNeeded"

There are three options available for languageEmbedding:
  1. asNeeded : This is default option (not recommended).
  2. always : This will include language code in URL
  3. never : This will not include language code in URL
Set languageEmbedding="never" to disable language code embedding in Sitecore.

Comments and suggestions are most welcome. Happy coding!  
Read More...