If you're trying to setup a more complex Sitecore environment. Perhaps, you're hosting two different websites. And for security reasons, not only do you want a separate Content Management server (CM) and a separate Content Delivery server (CD), maybe you want two CD servers. One for each site. How can you make that happen in SXA?
Well, we've already learned that the Site Groupings
tree can be constructed differently depending on our needs. Prior, we showed you how to setup a Preview server.
Exploring it further, we can see how we've currently assigned both the CM and the CD server to a single site definition. It works. It's not complicated. But it lacks any smarts.
Separate Site Definitions
First thing first is to create a separate Site Definition for CM and CD. This way we can target the environment the hostname will be for. It will make more sense in a minute.
Duplicate The Site Definition
Right click on the primary Site Definition and duplicate.
Rename the new Site Definition to correspond with the CM server. Then we will update the Site Name
, Target Hostname
and the Host Name
fields to be specific for the CM server. While it does work to have the Site Name
the same for the CD and CM Site nodes here, because only one operates per environment, it's better to name them different to ensure there are no complications during Site lookups. I suggest changing the CM Site Name by adding "Authoring" as an example to the end of the name. Of course any .NET code you use that has the Site name hard coded will need to be updated as well.
As an aside: If you are using Sitecore Identity Server and are using the loginPath
value where by you pass the site name in the URL, this will also need to be updated.
Now go back to the CD item and update the Target Hostname
and the Host Name
so that they properly point as well.
Update The Environment Name For CD Server
So to ensure that our company www site runs on an environment specific to that, we're going to update the field Valid for environment
to be a specific value instead of the default *
value.
We've gone ahead and updated the CD environment for the SECRETLIVE environment.
Validate With The SXA Site Manager
With that work out of the way, we can utilize the SXA Site Manager to validate our configuration. Go ahead and open it up from the Start menu on the Desktop. You'll find it listed under PowerShell Toolbox
.
Below you can see how there are no conflicts for our configuration of having separated the Content Management and Delivery servers along with having a separate environment for the second Content Delivery server.
Once everything looks well, go ahead and publish the site definitions.
Update The Environment Name In The SXA Multisite Config
Just updating the Site Definitions is not enough. We have to identify the server by a specific environment. How do we do this? Super simple.
You'll want to create a patch file specific to each CD environment. In our case we need two. One for the WWWLIVE environment and another for the SECRETLIVE.
The Patch File
What file are we patching? It's /App_Config/Modules/SXA/Foundation/Sitecore.XA.Foundation.Multisite.config
As for the line we need to patch, what you're looking for is as follows.
<setting name="XA.Foundation.Multisite.Environment" value="LIVE" />
The complete patch file for each environment would look like this.
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/">
<sitecore role:require="ContentDelivery">
<settings>
<setting name="XA.Foundation.Multisite.Environment" value="LIVE" >
<patch:attribute name="value">WWWLIVE</patch:attribute>
</setting>
</settings>
</sitecore>
</configuration>
We would then have a separate patch file for the SECRETLIVE Content Delivery server, which might look like this:
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/">
<sitecore role:require="ContentDelivery">
<settings>
<setting name="XA.Foundation.Multisite.Environment" value="LIVE" >
<patch:attribute name="value">SECRETLIVE</patch:attribute>
</setting>
</settings>
</sitecore>
</configuration>
Now do you need a patch file, no. Nothing is stopping you from updating the config directly on each CD server. It really depends on your project and what your deployment procedure is like.