This blog promotes knowledge sharing through experience and collaboration. For more product information, visit our WebSphere Commerce CSE page. For easier navigation, utilize the Categories to find posts that match your interest.
Stor-e-Time: Intro to SEO in Commerce
This is the first blog in a series in which we will dive into the SEO component of WebSphere Commerce. The aim of this series is to break down the SEO functionality to help you better understand the feature in Commerce. In this particular post, we will briefly discuss the basics of the SEO component.
What is Search Engine Optimization
SEO is an extremely important aspect for any site that exists on the web. Search engines crawl the internet and index sites based on several aspects of an algorithm that the search engine uses. For every site, the search results that are returned on a search engine matter greatly. The goal is to ensure that your site will have the highest ranking on a search engine and be displayed first - the site should be search engine optimized.
Words, titles, links, metadata - these are all important aspects that help to ensure your site is SEO friendly and Commerce addresses these aspects. To achieve high SEO results, the page must have keywords that stand out, rather than a jumble of incoherent words. Having the SEO URL contain coherent words will help to better index your site on search engines.
Why is SEO Important?
Having a site correctly SEO optimized will help to have your site ranked higher on search engines. This in turn could lead to more traffic resulting in more revenue etc. WebSphere Commerce has multiple ways of providing SEO capabilities:
Have a look at the following Knowledge Center document which discusses the above in detail: Overview of SEO in Commerce
What are the Components of an SEO URL in Commerce?
Now that the purpose of SEO is understood; the next key concept is to understand the three main components that make up SEO URLs in Commerce. This will help to understand how SEO URLs are constructed and deconstructed. The main components are:
The above diagram describes the relationship - each keyword is mapped to a specific type of token and each type of token is associated to a group of related keywords. These tokens are then mapped out in the pattern files which are used to finally construct and deconstruct the SEO URLs.
What are Keywords?
Each product and category will have a keyword that is associated with it. The purpose of this keyword is to make an entity (product or category) human readable. This is where the concept of SEO is pulled in - we want to ensure that the URL generated is something that can be understood. The ID for that entity is associated to a keyword which is used in a URL, making it understandable. The entire SEO URL that is generated is a combination of keywords that are put together for each link.
In the above example, we can see that the URLKEYWORD column makes much more sense than the SEOURLKEYWORD_ID column in understanding what link is being referenced.
What are Pattern Files?
Before we can jump into SEO construction/deconstruction, we need to understand what a pattern file is and the role they play. The pattern file consists of templates of how different types of URLs are meant to be structured. There are many types of pages that can be accessed (static, category, product) and for each of these types, a pattern file has one or more templates made up of tokens (discussed later) so that a URL can be constructed with the correct format.
We can use the SEO URL defined below to demonstrate how pattern files are used:
The URL that we have been working with matches the form of the above pattern, named ProductURLWithParentAndTopCategory within the <seourl:seoUrlPatternDef> tag:
The <seourl:seoUrlPattern> tag defines the viewName as "ProductDisplay" and sets our base token pattern to /LanguageToken/StoreToken:CatalogToken/CategoryToken/CategoryToken/CategoryToken/ProductToken.
There are two main sections to the seoUrlPatternDef, which are the inverse of each other:
You can read more on pattern files here: Constructing SEO-friendly URLs by using pattern files
What are Tokens?
Now that the concept of pattern files is understood, we can understand what tokens are and the relationship that exists with tokens and pattern files.
Tokens are placeholders that are used when constructing an SEO URL and are found in pattern files. Each type of token has a specific use and is associated with to a list of possible keywords and values. When constructing the URL, the list of tokens in a pattern file are replaced by their appropriate keywords. During deconstruction, the token names are resolved from the database (for a specific store to match the URL pattern.
There are two types of tokens - fixed and dynamic tokens.
Fixed tokens are tokens that can have a variety of values. For example, each time a new product is added, a new keyword is generated. This keyword will map to a specific TYPE of token and hence is the reason dynamic tokens can be associated to a variety of values unlike fixed tokens. Dynamic tokens are mainly used for product and category URLs. As the content of a catalog changes, in the same manner the list of dynamic tokens will be altered.
Here is a list of the types of dynamic tokens that can be seen OOB:
If we use the example of a ProductToken - this token is meant to map to a product. We can see how this is broken down in the diagram below:
You can read more on the types of tokens found in Commerce here: Constructing SEO-friendly URLs by using pattern files
What is SEO URL Construction/Deconstruction?
Using SEO URLs allows the URL that is constructed with a jumble of characters to be transformed into a URL that is human friendly. Although the SEO URL is now readable, Commerce will still rely on the non-SEO URL to carry out tasks. The SEO URL needs to be processed to find the matching embedded parameters - it needs to be converted back to a non-SEO URL or a standard URL to figure out which store, category and product exactly needs to be processed to show the requested data. This is the process of SEO URL deconstruction.
The same logic applies for SEO URL construction - the standard URL parameters are needed to convert the URL into a readable SEO URL.
This is the purpose of construction/deconstruction of URLs - we want SEO URLs because they provide great benefit to the site, but we need to be able to build/break them for Commerce to understand them.
What is the Context Root?
Before Commerce will process the URL, it needs to receive the URL first. When creating our instance, we define the context root on the server which essentially tells us - "Whenever you see this, send this request to Commerce".
The context root above is /webapp/wcs/stores/servlet. A common first step for clients is to shorten the context root by changing the wc-server.xml file and adding a rewrite rule in the httpd.conf file.
You can read more about context roots here: SEO
You can read more about shortening the context root here: Shortening the context root of a store URL
When is SEO URL construction/deconstruction carried out?
In a request built or received by Commerce, the context root is used to ensure the request is directed correctly. The remainder of the URL is what is either constructed or deconstructed.
Deconstruction of an SEO URL occurs when the request reaches the server. The URL will be broken down after the context root and parsed - the SEO parameters (keywords) will be mapped to their appropriate token values which are then used to render the requested page. You can find further details on this process here: SEO-friendly URL deconstruction overview
SEO URL construction is carried out when the JSP for a page is loaded. On any given page, there are a multitude of anchor tags that need to be present to link the variety of products and categories that would exist - however manually defining each can be avoided with URL construction. The <wcf:url> tag is used in the JSP to construct the URLs dynamically. This allows for the links on all the pages to be defined as soon as the page loads. You can read more on this process here: SEO-friendly URL construction overview
The flow of SEO URL construction/deconstruction will be covered in depth in a later blog.
Reviewing the example below, we can see the mapping that occurs during URL construction/deconstruction at a high level. Although the URLs look different, they are pointing to the same location. The colour coding shows how each part of URL is converted from SEO to non-SEO and vice versa.
How to Setup SEO?
Having discussed all the components of SEO - keywords, tokens and pattern files, we can now use these components to actually setup SEO. The relationship between the three needs to be created - the products and categories must have keywords associated to them. These keywords must map to a type of token and these tokens must be referenced by a template or multiple templates in the pattern files for the variety of URLs that can be created on your site.
How are Keywords Loaded?
Out of the box, tokens and patterns are pre-defined so the main focus would need to be on loading keywords. There are multiple methods of providing keywords that are necessary for SEO to be implemented. When initially loading products for a catalog, the seourlkeywordgen utility can be used to automatically generate the URL keywords. The seourlkeywordgen utility is designed to be used only once during site setup and migration to new SEO. You can read more on the seourlkeywordgen utility on the Knowledge Center: seourlkeywordgen utility
The second method to upload keywords is manually through CMC's Catalog Tool. If a user is creating or changing catalog entries or categories with the Catalog Tool, Management Center automatically generates keywords for the catalog objects.
Finally, dataload can be used to upload the URL keywords that are needed for the products and categories. You can read more on how dataload is used for SEO related entries at the following links: CatalogEntrySEO, CatalogGroupSEO
Creating Custom SEO URL Patterns
WebSphere Commerce will ship with a variety of OOB pattern files that can be used for the URLs that are generated. However, we do have additional documentation that discusses how you can further customize your site to create SEO URLs for new pages in the Aurora starter store at the following link: Tutorial: Defining Search Engine Optimization (SEO) URLs for new pages in the Aurora starter store
WebSphere Commerce SEO also includes the ability to employ 301 redirects for when the URL's keyword has been changed. This change can occur multiple times and each time the new URL will be redirected to from the old URL. You can read more on this functionality at the following link: URL redirects for SEO Overview
Commerce Version 8 vs Commerce Version 9
Fortunately, there are not many changes that have occurred in V9 in comparison to V8. The SEO logic is entirely the same - the three main components are still needed and are used to construct and deconstruct SEO URLs. The main difference occurs with the separation of servers - the files will be located in different locations and the way the request is directed will also be different. You can find more information on the differences in an upcoming blog.
This blog should have helped you to understand how SEO works with Commerce at a high level. Stay tuned for future blogs in this series where we will deep dive into how the different SEO functionalities work!