Loading

Cross site links are not working with API method URLUtils.abs for contents in B2C Commerce

Veröffentlichungsdatum: Nov 26, 2025
Beschreibung
In case you want to create cross site links for content within your code you use the API method URLUtils.abs to create these links.

As example you have the following setup for 2 sites (SG and DE)
  • Aliases
{
 "__version" : "1", 
 "settings" : {
   "http-host" : "<yourhostname>",
   "https-host" : "<yourhostname>",
   "site-path" : "SG",
   "default" : "true"
 }
}

and

{
 "__version" : "1", 
 "settings" : {
   "http-host" : "<yourhostname>",
   "https-host" : "<yourhostname>",
   "site-path" : "DE",
   "default" : "false"
 }
}
  • Within htmlhead.isml you creating the cross links with
<isscript>
	var langurl: String = "";	
	var params: Array;	
	params = [];
	params.push( dw.web.URLParameter("cid", request.httpParameters["cid"][0]) );
	langurlSG = URLUtils.abs(new dw.web.URLAction("Page-Show", "SiteGenesis"), params);	
	langurlDE = URLUtils.abs(new dw.web.URLAction("Page-Show", "DE"), params);		
</isscript>
<link rel="alternate" hreflang="default" href="${langurlSG}" />
<link rel="alternate" hreflang="default" href="${langurlDE}" />
  • When you have setup the content url like
[ [ folder ] , / , [ attribute, name, noname ] ]
  • You will get the following results when calling the content
calling from DE
<link rel="alternate" hreflang="default" href="https://<yourhostname>/SG/privacy%20policy/privacy-policy.html" />
<link rel="alternate" hreflang="default" href="https://<yourhostname>/DE/customer%20service/privacy%20%26%20security/privacy%20policy/privacy-policy.html" />

calling from SG
<link rel="alternate" hreflang="default" href="https://<yourhostname>/SG/customer%20service/privacy%20%26%20security/privacy%20policy/privacy-policy.html" />
<link rel="alternate" hreflang="default" href="https://<yourhostname>/DE/privacy%20policy/privacy-policy.html" />

 
Lösung

Content URL rule needs to be set to

[ [ folder, [ folder-parent, [ attribute, displayName], / ] ], / , [ attribute, name, noname ] ]


With this setup the urls are now looking identical

<link rel="alternate" hreflang="default" href="https://<yourhostname>/SG/customer%20service/privacy%20%26%20security/privacy%20policy/privacy-policy.html" />
<link rel="alternate" hreflang="default" href="https://<yourhostname>/DE/customer%20service/privacy%20%26%20security/privacy%20policy/privacy-policy.html" />
Zusätzliche Ressourcen

Class URLUtils

Nummer des Knowledge-Artikels

000391363

 
Laden
Salesforce Help | Article