Must have Sitecore path configurations

Posted 2 April 2015 12:00 AM by Alan Yip, Senior Sitecore Consultant @ ClearPeople

When creating a new website using Sitecore, lots of love and attention goes into designing, architecting, analysing, preparing, configuring and much more. Often, it’s easy to forget that the small things make a big difference in the development of the final product. 

I’m not talking about grammatical errors or missing images or even wrong content, I’m talking about things like SEO friendly URLs, 404 pages, KeepAlive settings, html cache clearing, SMTP settings and so on.

These are things that are sometimes taken for granted when you are deep into the development of code and definitely things that are rarely requested by your Project Management team or client. But they are things that should simply just be there!

I have to admit that I have learned the hard way in getting some of these things right first time and have been fortunate enough to have gained valuable experience in ensuring best practice going forward. I’ve put together this list of must-haves that will hopefully help any other developer who has faced the same problem and here is a list of the patch files that I have by default on any new project build:

SiteDefinition.config 

Useful for when you need to have different cache settings, domain, login page, etc.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <sites>
      <site name="website" patch:instead="site[@name='website']"
            virtualFolder="/
            physicalFolder="/
            rootPath="/sitecore/content
            startItem="/home
            database="web
            domain="extranet
            allowDebug="true
            cacheHtml="true
            htmlCacheSize="10MB
            registryCacheSize="0
            viewStateCacheSize="0
            xslCacheSize="5MB
            filteredItemsCacheSize="2MB
            enablePreview="true
            enableWebEdit="true
            enableDebugger="true
            disableClientData="false"
            loginPage="/login " />
    </sites>
  </
sitecore>
</
configuration>

SMTPSettings.config 

You will obviously need to set up where your emails will be sent out from.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <settings>
      <setting name="MailServer">
        <!-- Disallow dashes in item names for content editors because the above rule causes the page to crash -->
        <patch:attribute name="value">localhost</patch:attribute>
      </setting>
    </settings>
  </sitecore>
</configuration>

LinkManager.config 

This will set up SEO friendlier URLs and other settings like language embedding, include the ASPX extension or not, etc.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <linkManager defaultProvider="sitecore">
      <providers>
        <clear />
        <add name="sitecore" type="Sitecore.Links.LinkProvider, Sitecore.Kernel
             addAspxExtension="false
             alwaysIncludeServerUrl="false
             encodeNames="true
             languageEmbedding="never
             languageLocation="filePath
             lowercaseUrls="true
             shortenUrls="true
             useDisplayName="false"
             patch:instead="add[@name='sitecore']" />
      </providers>
    </
linkManager>    
  </
sitecore>
</
configuration>

KeepAlive.config

One that we always forget but it’s worth noting to include the domain of your site if you get a lot of 404s in your logs.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <scheduling>
      <agent type="Sitecore.Tasks.UrlAgent" method="Run" interval="00:30:00">
        <param desc="url">http://domain/sitecore/service/keepalive.aspx</param>
      </agent>
    </scheduling>
  </sitecore>
</configuration>

HtmlCacheClearer.config  

If you have more than one site or you have changed the name of your site, this is a must to make sure cache clearing is functioning correctly.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <events>
      <event name="publish:end">
        <handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCache">
          <sites hint="list">
            <site>website</site>
          </sites>
        </handler>
      </event>
      <event name="publish:end:remote">
        <handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCache">
          <sites hint="list">
            <site>website</site>         
          </sites>
        </handler>
      </event>
    </events>
  </sitecore>
</configuration>

EncodenameReplacements.config 

I’ve added a 2 in 1 here where I replace spaces with hyphens and also not allow hyphens to be used in item names.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <encodeNameReplacements>
      <replace mode="on" find=" " replaceWith="-" patch:after="replace[@replaceWith=',-c-,']" />
    </encodeNameReplacements>
    <settings>
      <setting name="InvalidItemNameChars">
        <!-- Disallow dashes in item names for content editors because the above rule causes the page to crash -->
        <patch:attribute name="value">-\/:?&quot;&lt;&gt;|[]</patch:attribute>
      </setting>
    </settings>
  </sitecore>
</configuration>

DataFolder.config 

Your data folder will certainly change in different projects so patching it here makes a lot of sense.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <sc.variable name="dataFolder">
      <patch:attribute name="value">C:\projects\website\Data</patch:attribute>
    </sc.variable>
  </sitecore>
</configuration>

404PageResolver.config 

I think by default you should always return a proper 404 response header so I patch this by default as well.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <pipelines>
      <httpRequestBegin>
        <processor type="Project.Pipelines._404PageResolver, Project"

                   patch:after="processor[@type='Sitecore.Pipelines.HttpRequest.ItemResolver, Sitecore.Kernel']"/>
      </httpRequestBegin>
    </pipelines>
  </sitecore>
</configuration>

500PageResolver.config

This is an additional one and there are many other options for 500 error setting, but I also patch it here too.

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <settings>
      <setting name="ErrorPage">
        <!-- Disallow dashes in item names for content editors because the above rule causes the page to crash -->
        <patch:attribute name="value">/MyErrors/500.html</patch:attribute>
      </setting>
    </settings>
  </sitecore>
</configuration>

With all the above patches, it also makes deployment a lot simpler because everything is all in one place. Plus it’s also best practice to always patch the configuration file rather than edit the web.config.

I hope this helps someone out as it has proved very useful for me. This is by no means an exhaustive list of patches I have, but some of the top must-have’s that I think all website build projects should include.

Thanks for reading and happy patching!

Share:

Add your comment

 
 

 

Archive

Tagcloud

Digital Transformation employee engagement staff satisfaction productivity Microsoft Teams Office 365 Yammer cms content management system agile GDPR Microsoft Graph collaboration Microsoft sharepoint 2016 upgrade migration SharePoint Online 2016 Tech Trends Digital Disruption Context marketing marketing SharePoint 2010 SharePoint 2013 TFS Git security kentico Analytics intranet jquery QA Quality Assurance testing digital workspace content management websites Sitecore sitecore marketplace sitecore module cloud Microsoft Cloud Storage digital strategy technical consulting sitecore modules Experience database Sitecore 7 Sitecore 8 support account management customer experience Data Storage windows azure cms integration front end front end development prototype Cloud Storage StorSimple Front-end Development Layout SharePoint 2013 colour palette UI design website design log viewer sitecore cms website Azure big data business-critical sharepoint accessibility android apple chrome clear people clearpeople debug emulator ios mobile testing opera resize adobe desktop flash ie10 internet explorer 10 metro windows 8 bcsp SharePoint Advanced System Reporter reporting framework ControlMode form control master page placeholder publishing console SharePoint 2007 SharePoint error search search results search values software testing testing scenario audit content information architecture retention schedules PowerShell QuickLaunch scripts SharePoint server 2010 business solutions metalogix replication replicator storagepoint stena technet UK Technet picture library slideshow web part RTM released to manufacturing caml caml query MOSS 2007 query infopath