Updating SEO patterns definitions to support device redirection

In this lesson, you update SEO URL patterns to use the new TopCategoriesDisplayView. You apply the changes that are made to the Struts configuration to forward requests to the device-specific storefront JSP. Also, more SEO URL patterns are required to support the smartphone starter store.

About this task

For example, the default SEO pattern definitions for the storefront home page are:

SEO Pattern File Struts action mapping SEO URL pattern
SEOURLPatterns.xml HomePageURLWithLang /LanguageToken/StoreToken:CatalogToken
mobileSEOURLPatterns.xml m20HomeURLWLang /Mobile20Token/LanguageToken/StoreToken:CatalogToken
TabletSEOURLPatterns.xml TabletHomeURL /TabletToken/LanguageToken/StoreToken:CatalogToken

Using a sample product page, Versatil Empire Waist Sundress, the SEO URL pattern definitions for each storefront are listed in the following table:

Storefront Sample SEO URL
Aurora starter store http://hostname/webapp/wcs/stores/servlet/en/aurora/apparel/women/dresses/versatil-empire-waist-sundress
Smartphone starter store http://hostname/webapp/wcs/stores/servlet/m20/en/aurora/versatil-empire-waist-sundress
Tablet starter store http://hostname/webapp/wcs/stores/servlet/t20/en/aurora/product/versatil-empire-waist-sundress

The SEO URL patterns for tablet and smartphone contain a storefront-specific token which can be removed once a common URL is defined for the selected storefronts. For example, m20 for smartphone and t20 for tablet. Removing the storefront token and adopting a device detection and redirection approach allows the smartphone and tablet starter stores to use the same URL as the Aurora starter store. For the above example product page, the common SEO URL becomes http://hostname/webapp/wcs/stores/servlet/en/aurora/apparel/women/dresses/versatil-empire-waist-sundress

For this tutorial, you will update and add the new definitions to the existing SEO URL pattern files. Where possible, the SEO URL patterns used in the Aurora starter store are adapted for use by the smartphone and tablet starter stores. When implementing a full SEO solution for your storefront, you may want to define your own SEO pattern files.

Procedure

SEO pattern changes for TopCategoriesDisplayView.
  1. In Enterprise Explorer, navigate to Stores > WebContent > WEB-INF > xml > seo > stores > Aurora. Open SEOURLPatterns.xml.
  2. Locate the SEO pattern definition for HomePageURLWithLang. The code resembles the following snippet:
    <seourl:seoUrlPatternDef name="HomePageURLWithLang">
    <seourl:seoUrlPattern viewName="TopCategoriesDisplay">/LanguageToken/StoreToken:CatalogToken</seourl:seoUrlPattern>
    …
    </seourl:seoUrlPatternDef>
  3. Replace viewName="TopCategoriesDisplay" with viewName="TopCategoriesDisplayView".
  4. Locate the SEO pattern definition for HomePageURL. The code resembles the following snippet:
    <seourl:seoUrlPatternDef name="HomePageURL">
    <seourl:seoUrlPattern viewName="TopCategoriesDisplay">/StoreToken:CatalogToken</seourl:seoUrlPattern>
    …
    </seourl:seoUrlPatternDef>
  5. Replace viewName="TopCategoriesDisplay" with viewName="TopCategoriesDisplayView".
  6. Save and close the file.
SEO pattern changes for smartphone starter store

The smartphone starter store defines views for pagination on category pages. In order to retain this functionality, new SEO patterns are required.

  1. In Enterprise Explorer, navigate to Stores > WebContent > WEB-INF > xml > seo > stores > Aurora. Open mobileSEOURLPatterns.xml.
  2. Locate the following fixed token:
    <seourl:token name="CurrentPageToken">
    <seourl:tokenValue value="[[0-9]*]"/>
    </seourl:token>
  3. Update the regular expression for the CurrentPageToken by locating the following line:
    <seourl:tokenValue value="[[0-9]*"/>

    Replace the asterisk (*) with a plus (+) sign, so the line resembles the following code:

    <seourl:tokenValue value="[[0-9]+]"/>

  4. Save and close the file.
  5. In Enterprise Explorer, navigate to Stores > WebContent > WEB-INF > xml > seo > stores > Aurora. Open mobileSEOURLPatterns-Category.xml.
  6. Add the following code snippet to the end of the list of SEO URL pattern definitions, within the <seourl:seoUrlConfiguration> block.
    <seourl:seoUrlPatternDef name="CategoryURLWPaging">
    	<seourl:seoUrlPattern viewName="CategoryDisplay">/LanguageToken/StoreToken:CatalogToken/CategoryToken/CategoryToken/CurrentPageToken</seourl:seoUrlPattern>  
    	<seourl:urlToParamMapping>
    		<seourl:mapping name="langId" value="?LanguageToken?"/>
    		<seourl:mapping name="storeId" value="?StoreToken?"/>
    		<seourl:mapping name="catalogId" value="?CatalogToken?"/>
    		<seourl:mapping name="top_category" value="?CategoryToken?"/>
    		<seourl:mapping name="parent_category_rn" value="?CategoryToken?"/>
    		<seourl:mapping name="categoryId" value="?CategoryToken.1?"/>
    		<seourl:mapping name="currentPage" value="?CurrentPageToken?"/>
    	</seourl:urlToParamMapping>
    	<seourl:paramToUrlMapping>
    		<seourl:mapping name="LanguageToken" value="?langId?"/>
    		<seourl:mapping name="StoreToken" value="?storeId?"/>
    		<seourl:mapping name="CatalogToken" value="?catalogId?"/>
    		<seourl:mapping name="CategoryToken" value="?top_category?"/>
    		<seourl:mapping name="CategoryToken.1" value="?categoryId?"/>
    		<seourl:mapping name="CurrentPageToken" value="?currentPage?" defaultValue="1"/>
    	</seourl:paramToUrlMapping>
    	<seourl:usageDef>
    		<seourl:usage device="mobile">
    			<seourl:target>CatalogGroup</seourl:target>
    		</seourl:usage>
    	</seourl:usageDef>
    </seourl:seoUrlPatternDef>
    
    <seourl:seoUrlPatternDef name="CategoryURLWParentCategoryAndPaging">
    	<seourl:seoUrlPattern viewName="CategoryDisplay">/LanguageToken/StoreToken:CatalogToken/CategoryToken/CategoryToken/CategoryToken/CurrentPageToken</seourl:seoUrlPattern>  
    	<seourl:urlToParamMapping>
    		<seourl:mapping name="langId" value="?LanguageToken?"/>
    		<seourl:mapping name="storeId" value="?StoreToken?"/>
    		<seourl:mapping name="catalogId" value="?CatalogToken?"/>
    		<seourl:mapping name="top_category" value="?CategoryToken?"/>
    		<seourl:mapping name="parent_category_rn" value="?CategoryToken.1?"/>
    		<seourl:mapping name="categoryId" value="?CategoryToken.2?"/>
    		<seourl:mapping name="currentPage" value="?CurrentPageToken?"/>
    	</seourl:urlToParamMapping>
    	<seourl:paramToUrlMapping>
    		<seourl:mapping name="LanguageToken" value="?langId?"/>
    		<seourl:mapping name="StoreToken" value="?storeId?"/>
    		<seourl:mapping name="CatalogToken" value="?catalogId?"/>
    		<seourl:mapping name="CategoryToken" value="?top_category?"/>
    		<seourl:mapping name="CategoryToken.1" value="?parent_category_rn?"/>
    		<seourl:mapping name="CategoryToken.2" value="?categoryId?"/>
    		<seourl:mapping name="CurrentPageToken" value="?currentPage?" defaultValue="1"/>
    	</seourl:paramToUrlMapping>
    	<seourl:usageDef>
    		<seourl:usage device="mobile">
    			<seourl:target>CatalogGroup</seourl:target>
    		</seourl:usage>
    	</seourl:usageDef>
    </seourl:seoUrlPatternDef>
    	
    <seourl:seoUrlPatternDef name="TopCategoryURLWPaging">
    	<seourl:seoUrlPattern viewName="CategoryDisplay">/LanguageToken/StoreToken:CatalogToken/CategoryToken/CurrentPageToken</seourl:seoUrlPattern>  
    	<seourl:urlToParamMapping>
    		<seourl:mapping name="langId" value="?LanguageToken?"/>
    		<seourl:mapping name="storeId" value="?StoreToken?"/>
    		<seourl:mapping name="catalogId" value="?CatalogToken?"/>
    		<seourl:mapping name="categoryId" value="?CategoryToken?"/>
    		<seourl:mapping name="top" value="Y"/>
    		<seourl:mapping name="currentPage" value="?CurrentPageToken?"/>
    	</seourl:urlToParamMapping>
    	<seourl:paramToUrlMapping>
    		<seourl:mapping name="LanguageToken" value="?langId?" defaultValue="-1"/>
    		<seourl:mapping name="StoreToken" value="?storeId?"/>
    		<seourl:mapping name="CatalogToken" value="?catalogId?"/>
    		<seourl:mapping name="CategoryToken" value="?categoryId?"/>
    		<seourl:mapping name="CurrentPageToken" value="?currentPage?" defaultValue="1"/>
    	</seourl:paramToUrlMapping>
    	<seourl:usageDef>
    		<seourl:usage device="mobile">
    			<seourl:target>CatalogGroup</seourl:target>
    		</seourl:usage>
    	</seourl:usageDef>
    </seourl:seoUrlPatternDef>
  7. Save and close the file.
  8. In Enterprise Explorer, navigate to Stores > WebContent > WEB-INF > xml > seo > stores > Aurora. Open SEOURLPatterns-Product.xml.
  9. Locate the <seourl:seoUrlPatternDef name="CanonicalItemURLWithCategory"> element and comment out the entire element.
    This SEO URL pattern is not used by the default Aurora storefront, but the pattern is shared with the TopCategoryURLWPaging which conflicts during URL deconstruction. For this tutorial, the pattern can be safely commented out.
  10. Restart the server to reload the changes to the SEO pattern files. Note: If you are using a development environment, the restart step may not be necessary if you enabled the reload file (see section: Best practices for working with pattern files).