Search Engine Optimization (SEO) has become a key concern for many marketers. As a result, SEO concerns need to be addressed on many AEM projects. Please read SEO and URL Management Best Practices for additional information.
AEM CIF Core Components provides advanced configurations to customize the URLs for product and category pages. Many implementations will customize these URLs for search engine optimization (SEO) purposes. The following video details how to configure the UrlProvider
Service and features of Sling Mapping to customize the URLs for product and category pages.
To configure the UrlProvider
service according to the SEO requierments and needs a project must provide an OSGI configuration for the “CIF URL Provider configuration”.
Since release 2.0.0 of the AEM CIF Core Components, the URL Provider configuration only provides pre-defined url formats, instead of the free-text configureable formats kown from 1.x releases. Furthermore the use of selectors to pass data in URLs has been replaced with suffixes.
This configures the URLs of the product pages and supports the following options:
{{page}}.html/{{sku}}.html#{{variant_sku}}
(default){{page}}.html/{{url_key}}.html#{{variant_sku}}
{{page}}.html/{{sku}}/{{url_key}}.html#{{variant_sku}}
{{page}}.html/{{url_path}}.html#{{variant_sku}}
{{page}}.html/{{sku}}/{{url_path}}.html#{{variant_sku}}
In the case of the Venia Reference store:
{{page}}
will be replaced by /content/venia/us/en/products/product-page
{{sku}}
will be replaced by the product’s sku, e.g. VP09
{{url_key}}
will be replaced by the product’s url_key
property, e.g. lenora-crochet-shorts
{{url_path}}
will be replaced by the product’s url_path
, e.g. venia-bottoms/venia-pants/lenora-crochet-shorts
{{variant_sku}}
will be replaced by the currently selected variant, e.g. VP09-KH-S
Since the url_path
got deprecated, the pre-defined product URL formats use a product’s url_rewrites
and pick the one with the most path segmenents as alternative if the url_path
is not available.
With the above example data, a product variant URL formatted using the default URL format will look like /content/venia/us/en/products/product-page.html/VP09.html#VP09-KH-S
.
This configures the URLs of the category or product list pages and supports the following options:
{{page}}.html/{{url_path}}.html
(default){{page}}.html/{{url_key}}.html
In the case of the Venia Reference store:
{{page}}
will be replaced by /content/venia/us/en/products/category-page
{{url_key}}
will be replaced by the category’s url_key
property{{url_path}}
will be replaced by the category’s url_path
With the above example data, a category page URL formatted using the default URL format will look like /content/venia/us/en/products/category-page.html/venia-bottoms/venia-pants.html
.
The url_path
is a concatenation of the url_keys
of a product or category’s ancestors and the product or category’s url_key
separated by /
slash.
It is possible to create multile category and product pages for only a specific subset of categories or products of a catalog.
The UrlProvider
is pre-configured to generate deep links to such pages on author tier instances. This is useful to editors, that browse a site using Preview mode, navigate to a specific product or category page and switch back to Edit mode to edit the page.
On publish tier instances on the other hand, catalog page urls should be kept stable to not lose gains on search engine rankings for example. Because of that publish tier instances will not render deep links to specific catalog pages per default. To change this behaviour, the CIF URL Provider Specific Page Strategy can be configured to always generate specific page urls.
To provide a custom URL format a project can implement etiher the ProductUrlFormat
or the CategoryUrlFormat
service interface and register the implementation as OSGI service. Those implementations, if available, will replace the configured, pre-defined format. If there are multiple implementations registered, the one with the higher service ranking replaces the one(s) with the lower service ranking.
The custom URL format implementations must implement a pair of methods to build a URL from given parameters, and to parse a URL to return the same parameters respectively.
In addition to the UrlProvider
, it is also possible to configure Sling Mappings in order to rewrite and process URLs. The AEM Archetype project also provides an example configuration to configure some Sling Mappings for port 4503 (publish) and 80 (dispatcher).
URL rewrites can also be achived by using AEM Dispatcher HTTP server with mod_rewrite
module. The AEM Project Archetype provides a reference AEM Dispatcher config which already includes basic rewrite rules for the generated size.
The Venia Reference store project includes sample configurations to demonstrate the usage of custom URLs for product and category pages. This allows each project to set up individual URL patterns for product and category pages according to their SEO needs. A combination of CIF UrlProvider
and Sling Mappings as described above is used.
This configuration must be adjusted with the external domain used by the project. The Sling Mappings are working based on the hostname and domain. Therefore this configuration is disabled by default and must be enabled before deployment. To do so rename the Sling Mapping hostname.adobeaemcloud.com
folder in ui.content/src/main/content/jcr_root/etc/map.publish/https
according to the used domain name and enable this config by adding resource.resolver.map.location="/etc/map.publish"
to the JcrResourceResolver
config of the project.