Configuring URLs
Description
This article provides an overview of how URLs and slugs for various entities within the system are configured and managed, including products, categories, and other content types.
Configuration
URL Format Configuration
This configuration defines the URL structure patterns for different entity types in the application.
Structure
Configuration Properties
| Property | Description | Available Segments |
|---|---|---|
Brand | URL pattern for brand pages | Market, Language, Brand |
Category | URL pattern for category pages | Market, Language, Category (expandable) |
Product | URL pattern for product pages | Market, Language, Category (expandable), Brand, Product |
DiscountCampaign | URL pattern for discount campaign pages | Market, Language, DiscountCampaign |
PageWidgetCollection | URL pattern for page widget collections | Market, Language, PageWidgetCollection |
Parameter | URL pattern for parameter pages | Market, Language, Parameter |
Default | Default URL pattern for entities without specific patterns | Market, Language, Alias |
MaxCategoryDepth | Maximum depth for category hierarchy expansion (default: 4) | N/A |
Available Segments
All entity types support the following base segments:
Market- The market identifierLanguage- The language code
Entity-specific segments are listed in the table above and can be used within their respective URL patterns.
Special Syntax
- Static Segments: Adding
!after a segment (e.g.,l!) marks it as static and prevents replacement with entity slugs - Optional Segments: Market and Language segments can be omitted if multi-market functionality is not used
- Category Expansion: Categories are expanded hierarchically according to the
MaxCategoryDepthsetting
Example Output
Given the following configuration:
{
"Urls": {
"Brand": "/b!/{Brand}",
"Category": "/c!/{Category}",
"Product": "/p!/{Category}/{Product}",
"DiscountCampaign": "/dc!/{DiscountCampaign}",
"PageWidgetCollection": "/page!/{PageWidgetCollection}",
"Parameter": "/param!/{Parameter}",
"MaxCategoryDepth": 4
}
}
The resulting URLs could be:
- Brand:
/b/nike - Category:
/c/electronics/phones - Product:
/p/electronics/phones/iphone-13 - Discount Campaign:
/dc/summer-sale - Page Widget Collection:
/page/homepage - Parameter:
/param/blue
Default Configuration
The default URL configuration is as follows:
{
"UrlFormat": {
"Brand": "/Market/Language/l!/Brand",
"Category": "/Market/Language/l!/Category",
"Product": "/Market/Language/p!/Category/Product",
"DiscountCampaign": "/Market/Language/l!/DiscountCampaign",
"PageWidgetCollection": "/Market/Language/PageWidget",
"Parameter": "/Market/Language/l!/parameter",
"MaxCategoryDepth": 4
}
}
History
When an entity is renamed, a new slug is generated, and the old slug is retained in a history log to ensure existing URLs remain valid. This allows for seamless redirection from old URLs to the updated ones.
The history log can be accessed via the Management API, enabling developers to retrieve previous slugs and implement custom redirection logic if needed.
In the merchant api, when fetching an entity by slug, the system automatically checks the history log to find the current slug if an old slug is used. The same is done for the rest of the segments in the URL, resulting in a canonical URL being returned. If the canonical URL differs from the requested URL, the caller can choose to redirect the user to the canonical URL.