CRS is configured to render a link tag on each page that specifies the canonical URL for the page. When web spiders for certain search engines crawl a page, they record the page’s URL as the value specified in the tag, rather than the actual URL that was used to access the page.

The link tag for a page looks something like this:

<link rel="canonical" ref="http://www.example.com:80/store/jump/
Lissadel+Decanter/productDetail/Glassware/xprod2046/cat10020" />

To code your JSPs to render canonical URLs, use the URL recoding feature described in the URL Recoding section. The canonical URL in the link tag will be similar to the static URL rendered for web spiders by an indirect URL template. The main difference is that the canonical URL will always be static, regardless of whether the page is accessed by a spider or a human user. That way, if a spider happens to access a page using a dynamic URL (e.g., by following a link from another page), it will still see (and record) the static URL it finds in the link tag. As with the URL recoding feature, when a user accesses a page via a static URL, the SEO jump servlet is used to translate it back to its dynamic equivalent for processing.

To render canonical URLs, you use the atg.repository.seo.CanonicalItemLink servlet bean. CRS includes a component of this class, /atg/repository/seo/CanonicalItemLink, which is configured as follows:

itemDescriptorNameToUrlTemplateMap=\
        product=/atg/repository/seo/ProductIndirectTemplate,\
        category=/atg/repository/seo/CategoryIndirectTemplate

defaultRepository=/atg/commerce/catalog/ProductCatalog
defaultItemDescriptorName=product

The /global/gadgets/canonicalTag.jsp gadget invokes the CanonicalItemLink servlet bean to render the canonical URL for a product detail page:

<dsp:droplet name="/atg/repository/seo/CanonicalItemLink">
  <dsp:param name="id" param="productId" />
  <dsp:param name="itemDescriptorName" value="product" />
  <dsp:param name="repositoryName" value="/atg/commerce/catalog/ProductCatalog" />
  <dsp:oparam name="output">
    <dsp:getvalueof var="pageUrl" param="url" vartype="java.lang.String" />
    <link rel="canonical" href="${httpLink}${pageUrl}" />
  </dsp:oparam>
</dsp:droplet>
 
loading table of contents...