Monday, February 14, 2022

Migrating Legacy Multisite Sitecore Project into Sitecore JSS

  In most recent times, we tend to upgrade to a higher version. Similarly, legacy Sitecore applications are also planning to migrate into Sitecore latest version. Since Sitecore offers flexible features in the latest JSS releases.     

  Problem: 

          In our scenario, we wanted to rewrite the legacy Multisite application into Sitecore JSS without SXA and Headless. Once we have rewritten, the application structure is looked at as below. Site-B does not inherit Site-A as Sitecore out of box feature.


Solution :         

       We have to inherit the Site-A items into Site-B. Only the dictionary content between Site-A and Site-B is different.

           To achieve this, follow the below steps:

  •     Add custom site definition in the Sitecore.JavaScriptServices.Apps.config


  <?xml version="1.0" encoding="utf-8" ?>

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">

  <sitecore>

    <javaScriptServices>

      <apps>

          <app name="custom-defaults"

          filesystemPath="/dist/SiteA"

          serverBundle="server.bundle"

          importUser="sitecore\JssImport"

          importLanguage="en"

          importDatabase="master"

          importDevice="/sitecore/layout/Devices/Default"

          templatesPath="/sitecore/templates/Project/SiteA"

          renderingsPath="/sitecore/layout/renderings/Project/SiteA"

          layoutPath="/sitecore/layout/Layouts/Project/presto-contactless/SiteB Layout"

          placeholdersPath="/sitecore/layout/placeholder settings/Project/SiteA"

          appDatasourcesPath="$sitecorePath/Components"

          dictionaryPath="$sitecorePath/SiteB Dictionary"

          dictionaryDomain="SiteB Dictionary"

          routeDatasourcesPath="Page Components"

          mediaLibraryPath="/sitecore/media library/SiteA"

          ...

      </apps>

    </javaScriptServices>

  </sitecore>

</configuration>

  • In the Apps config  inherit the custom created site definition.
   <javaScriptServices>
      <apps>
        <!--
          JSS App Registration        
       
        <app name="SiteB"
             sitecorePath="/sitecore/content/SiteB"
             useLanguageSpecificLayout="true"
             graphQLEndpoint="/api/SiteB"
             inherits="custom-defaults"
        />
      </apps>

      


   In this model, I tried only Sitecore First Approach. By this inheritance, Sites can still share the templates, Layouts.




    

         

 

    

No comments:

Post a Comment