Tailwind Logo

Changing Sitecore Settings - File Handling

Experience Manager (XM)

Published: 2021-08-11

Last time, we covered key points about the Media Library. Now, let's delve into some frequently asked topics regarding Sitecore configuration: handling configuration files and deploying files not managed by Sitecore.

About the configuration file

This is exactly what we did last time when we introduced the Sitecore Media Library. In doing so, I introduced the Sitecore media library by suggesting that you change the settings in Sitecore.config, even though this was a bit rough. If you change the configuration directly, you will not be able to see what you have edited in the actual operation.

For this reason, it is possible to create and merge patch files to clarify the changes made. This is described in the following document.

As for the configuration files, the flow is to place the diff configuration files under /App_Config/Include and change the settings at startup.

Incidentally, as a tool to check the configuration information at startup, you can open the Control Panel - Administrative Tools and start the Show Config tool to check the configuration.

config01.png

When the tool is launched, the XML data is displayed.

config02.png

You will see the following regarding HTML

config03.png

I would like to actually create a Patch file. Create the following file named MediaType.HTML.Disable.ForceDownload.config in the folder /App_Config/Include/Settings/.

XML
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <mediaLibrary>
      <mediaTypes>
        <mediaType name="HTML" extensions="htm,html,stm">
          <forceDownload>
            <patch:delete />
          </forceDownload>
          <forceDownload>false</forceDownload>
        </mediaType>
      </mediaTypes>
    </mediaLibrary>
  </sitecore>
</configuration>

After creating this file, I checked the settings again and they have been updated as follows.

config04.png

Creating a path not to be processed by Sitecore

Sitecore basically processes the content on the server where Sitecore is running, but there are cases where you may want to place a file on the server. For example

  • We are considering a form of phasing and migrating by subdirectory.
  • You don't need to manage existing HTML files, but want to place them or display them as pages
  • Accelerate CMS conversion for frequently edited areas, and leave all other files as they are.

To do this, simply specify the target directory in the IgnoreUrlPrefixes field of Sitecore.config. The default is multiple directories, so use | to add more. The following code shows the case where campaign is added at the end and HTML files are placed there.

XML
    <setting name="IgnoreUrlPrefixes" value="/sitecore/default.aspx|/trace.axd|/webresource.axd|/sitecore/shell/Controls/Rich Text Editor/Telerik.Web.UI.DialogHandler.aspx|/sitecore/shell/applications/content manager/telerik.web.ui.dialoghandler.aspx|/sitecore/shell/Controls/Rich Text Editor/Telerik.Web.UI.SpellCheckHandler.axd|/Telerik.Web.UI.WebResource.axd|/sitecore/admin/upgrade/|/layouts/testing|/sitecore/service/xdb/disabled.aspx|campaign" />

If you place an HTML file here and specify an image, you will see that a normal page is displayed as shown below.

config05.png

You can then use GitHub Actions or Azure DevOps Pipeline as a way to deploy the files to the target directory, and you can determine the steps to deploy the files to the server.

Summary

In this article, we have introduced the configuration procedure and two methods of deploying files that are not managed by Sitecore. Both of these are common deployment patterns in actual operation, so please keep them in mind.

Tags