Resolved: Unable to add a new publishing target in Sitecore 10.3

Posted by

You all must be aware of the term ‘Publishing Target’ and the purpose of creating one, if you are new to that there are quite many articles explaining so, I suggest giving it a quick read first.

So jumping to our problem statement now. We have been working with publishing targets since long now starting Sitecore 7. I was also very clear about the same until I tried doing it in Sitecore 10.3 which has some additional steps, which if not done can land you up with the following error:

Value cannot be null.
Parameter name: item”

Now after encountering this error, like any other developer I searched the community support for the bugfix but to my surprise I couldn’t find any blog which can help me with the solution at the time of writing this post. So here am I to give back to my Sitecore community.

I have laid down the complete steps for adding a new publishing target in Sitecore 10.3, please make sure to follow all the steps to resolve this issue:

  • Deploy a new database in SQL Server
  • Update the ConnectionString.config in our application and add newly deployed database.

    <add name="staging" connectionString="user id=sa;password=sa;Data Source=.;Database=Stagingdb"/>
  • Create a configuration patch file similar to this.
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <eventing defaultProvider="sitecore">
      <eventQueueProvider>
        <eventQueue name="staging" 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="staging" 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>
      <database id="staging" 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>
      </database>
    </databases>
  </sitecore>
</configuration>
  • In the App_Data\items\ folder, make a copy of the Web folder.
  • Rename the copy of the folder and the .dat file inside it. Use the database name for the folder (for example, staging) and use the database name within the file name, so it is like items.staging.dat).
  • Creating new item in master database under “/sitecore/system/Publishing targets”.
  • Add Target Database name in the field (same as database id).
    Once done, navigate to any item and go to publish item.

You will be able to see newly added publishing target.

Happy Coding!

Leave a Reply