System

Configuring URLs

Configuring URLs and slugs for products, categories, and other entities

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.

Most entities can have slugs that are used to create user-friendly URLs. These slugs are unique identifiers over all entities. When an entity is created or updated, the system automatically generates a slug based on the entity's name or title. If a slug already exists, the system appends a unique number suffix to ensure uniqueness. Example: "my-product", "my-product-1", "my-product-2".

Configuration

URL Format Configuration

This configuration defines the URL structure patterns for different entity types in the application.

Structure

Configuration Properties

PropertyDescriptionAvailable Segments
BrandURL pattern for brand pagesMarket, Language, Brand
CategoryURL pattern for category pagesMarket, Language, Category (expandable)
ProductURL pattern for product pagesMarket, Language, Category (expandable), Brand, Product
DiscountCampaignURL pattern for discount campaign pagesMarket, Language, DiscountCampaign
PageWidgetCollectionURL pattern for page widget collectionsMarket, Language, PageWidgetCollection
ParameterURL pattern for parameter pagesMarket, Language, Parameter
DefaultDefault URL pattern for entities without specific patternsMarket, Language, Alias
MaxCategoryDepthMaximum depth for category hierarchy expansion (default: 4)N/A

Available Segments

All entity types support the following base segments:

  • Market - The market identifier
  • Language - 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 MaxCategoryDepth setting

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.