Create a publishing target

Current version: 10.3

A publishing target consists of a database and a publishing target definition item that specifies that database. Sitecore publishes from the Master database to one or more publishing target databases. The Master database contains all versions of all data, including unapproved content changes.

The default publishing target, Internet, references the database named Web, but you can create additional publishing targets.

Reasons to create additional publishing targets include:

  • Geographic distribution: you can publish all content to multiple publishing targets on content delivery servers in multiple locations.

  • You want to publish to a preview publishing target before publishing to your live site.

To create a publishing target:

  1. Deploy a new database, for example by using the Web database from the installation package for your version of Sitecore.

  2. In the ConnectionStrings.config file on your CM server, add an entry similar to this:

    RequestResponse
    <add name="preview" connectionString="Data Source=.;Initial Catalog=web_preview;User ID=;Password=" />
    Note

    To use the database for content delivery instead of preview, add a connection on your CD server.

  3. Create a configuration patch file similar to this (the settings are in the Sitecore.config file):

    RequestResponse
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
      <sitecore>
        <eventing defaultProvider="sitecore">
          <eventQueueProvider>
            <eventQueue name="web_preview" patch:after="eventQueue[@name='web']" type="Sitecore.Data.Eventing.$(database)EventQueue, Sitecore.Kernel">
              <param ref="dataApis/dataApi[@name='$(database)']" param1="$(name)" />
              <param hint="" ref="PropertyStoreProvider/store[@name='$(name)']" />
            </eventQueue>
          </eventQueueProvider>
        </eventing>
        <PropertyStoreProvider>
          <store name="web_preview" patch:after="store[@name='web']" prefix="web_secondary" getValueWithoutPrefix="true" singleInstance="true" type="Sitecore.Data.Properties.$(database)PropertyStore, Sitecore.Kernel">
            <param ref="dataApis/dataApi[@name='$(database)']" param1="$(name)" />
            <param resolve="true" type="Sitecore.Abstractions.BaseEventManager, Sitecore.Kernel" />
            <param resolve="true" type="Sitecore.Abstractions.BaseCacheManager, Sitecore.Kernel" />
          </store>
        </PropertyStoreProvider>
        <databases>
          <!-- web_secondary -->
          <database id="web_preview" patch:after="database[@id='web']" singleInstance="true" type="Sitecore.Data.DefaultDatabase, Sitecore.Kernel">
            <param desc="name">$(id)</param>
            <icon>Images/database_web.png</icon>
            <securityEnabled>true</securityEnabled>
            <dataProviders hint="list:AddDataProvider">
              <dataProvider type="Sitecore.Data.DataProviders.CompositeDataProvider, Sitecore.Kernel">
              <param desc="readOnlyDataProviders" hint="list">
                <protobufItems type="Sitecore.Data.DataProviders.ReadOnly.Protobuf.ProtobufDataProvider, Sitecore.Kernel">
                  <filePaths hint="list">
                    <filePath>$(dataFolder)/items/$(id)</filePath>
                    <modulesFilePath>/sitecore modules/items/$(id)</modulesFilePath>
                  </filePaths>
                </protobufItems>
              </param>
          <param desc="headProvider">
                  <dataProvider ref="dataProviders/main" param1="$(id)">
                    <disableGroup>publishing</disableGroup>
                    <prefetch hint="raw:AddPrefetch">
                      <sc.include file="/App_Config/Prefetch/Common.config" />
                      <sc.include file="/App_Config/Prefetch/Webdb.config" />
                    </prefetch>
                  </dataProvider>
                </param>
              </dataProvider>
            </dataProviders>
            <PropertyStore ref="PropertyStoreProvider/store[@name='$(id)']" />
            <remoteEvents.EventQueue>
              <obj ref="eventing/eventQueueProvider/eventQueue[@name='$(id)']" />
            </remoteEvents.EventQueue>
            <archives hint="raw:AddArchive">
              <archive name="archive" />
              <archive name="recyclebin" />
            </archives>
            <cacheSizes hint="setting">
              <data>100MB</data>
              <items>50MB</items>
              <paths>2500KB</paths>
              <itempaths>50MB</itempaths>
              <standardValues>2500KB</standardValues>
            </cacheSizes>
            <BlobStorage hint="raw:AddBlobStorage">
               <providers default="classic">
                  <provider name="classic" type="Sitecore.Data.Blobs.ClassicSqlBlobProvider, Sitecore.Kernel">
                     <param desc="databaseName">$(id)</param>
                  </provider>
               </providers>
            </BlobStorage>
          </database>
        </databases>
      </sitecore>
    </configuration>
  4. In the App_Data\items\ folder, make a copy of the Web folder.

  5. Rename the copy of the folder and the .dat file inside it. Use the database name for the folder (for example, web_preview) and use the database name within the file name, so it is similar to items.web_preview.dat).

  6. Some additional steps are required if you have SXA installed. If you have a sitecore modules\items\ folder:

    1. In the sitecore modules\items\ folder, make a copy of the web folder.

    2. Rename the copy of the folder and the .dat file inside it. Use the database name for the folder (for example, web_preview) and use the database name within the file name, so it is similar to items.web_preview.sxa.dat.

  7. If you need a search index for the new database, copy the one for sitecore_web_index in the App_Config\Sitecore\ContentSearch\Sitecore.ContentSearch.Solr.Index.Web.config, and change it so that the crawler uses the new database. You must also change the index update strategy to get data from the new database.

  8. To create a new index update strategy, copy the existing onPublishEndAysnc or OnPublishEndAsyncSingleInstance index update strategy, give it a new name, for example, onPublishToPreviewEndAsync, and change the database parameter of the strategy to the name of the publishing target.

Do you have some feedback for us?

If you have suggestions for improving this article,