How to create SEO Urls in WebSphere Commerce(WCS)

To avoid having to hard code SEO friendly URLs in the storefront pages, the WebSphere Commerce Search Engine Optimization feature provides a wcf:url tag that will construct SEO friendly URLs using the SEO pattern file(s) and tables.

The current wcf:url tag is used by all starter stores to construct SEO friendly URLs. The UrlTag class has been enhanced to support the use of the new URL pattern definition to create SEO friendly URLs.

In case you open any JSP , for example SiteMap_Data.jspf, you will notice that our old friend <c:url> tag which was used to construct the URLs in WCS6 has been replaced by <wcf:url>. So, let us spend some time leaning about the tag. 

About the wcf:url tag

The wcf:url tag builds a URL and applies the appropriate WebSphere Commerce supported rewriting rules.

It contains the following additions compared to the c:url tag:

  • It builds a full path URL, rather than a relative path.
  • It builds SEO compliant URLs if the feature is used in WebSphere Commerce.
  • It adds a prefix to the URL with the appropriate protocol, HTTP or HTTPS, depending on the Struts configuration files.

To know more about the tag and its parameters , please refer Infocenter.

Either value or patternName is required. If workspace is used, then both value and patternName are required. If the value parameter is provided, then URLs will be constructed based on the mapping found inSEOUrlMapper.xml file using the SEO implementation from WebSphere Commerce new versions. If patternName is provided and SEO is enabled in wc-server.xml as shown in the following example, then URLs will be constructed based on the SEO design, using the pattern template definitions. Preference will be given to the patternName attribute over the value attribute. 

If URL construction using patternName fails (due to an invalid patternName or a missing parameter), dynamic URL’s will be constructed if the dynamicUrl attribute is set to true. If dynamicUrl is set to false, then wcf:url tag returns defaultUrl specified in wc-server.xml 

The URL creation order is:

  1. If SEO Enabled and patternName specified, use patternName and construct new SEO URL
    • If new SEO URL construction fails and dynamicUrl = true, a dynamic URL is constructed
    • If dynamicUrl = false, a defaultUrl is constructed
  2. Otherwise the value attribute is used an old SEO URL is constructed

The following diagram helps understand the SEO URL differences and the tag parameters :

Example
The following example forms a URL to display the shopping cart using the

<wcf:url> tag. It specifies the URL type as an AJAX call.

<wcf:url var="currentShoppingCartLink" value="ShopCartPageView" type="Ajax">

   <wcf:param name="storeId"   value="${WCParam.storeId}"  />

   <wcf:param name="catalogId" value="${WCParam.catalogId}"/>

   <wcf:param name="langId" value="${WCParam.langId}" />

</wcf:url>

Leave a Reply