Support slash in UrlPath translations
We have a need to identify language in URLs.
This resembles adding /fr to the URL path of our french pages in the URL Segment of the French homepage and the UrlRoot (i.e CatalogUrlRoot = fr/catalogue, ProductUrlRoot = fr/produit, Brand_UrlRoot = fr/marques
Current setting does not support adding a slash (/ in the UrlPath translations, which is causing undesirable user experiences and language display issues.
Benefits to adding this feature:
SEO:
Search engines (like Google can easily recognize language-specific content when it's separated by a path (i.e., /fr for French. This helps with international SEO, making it easier to index and rank pages in the relevant language markets.
User Experience:
Users can easily identify the page's language by looking at the URL, which enhances usability and makes navigation more predictable, especially on multilingual sites.
If users share a link, the URL will immediately indicate the language, which is particularly helpful
Simplifies site structure:
A /fr structure keeps language variations in an organized hierarchy within the main domain, making it easier to manage language-specific content and maintain consistent tracking or analytics per language version.
Great news! Our team has added this new feature and it was included in September-sts release - 5.2.2609.386+sts.
Unified multilingual catalog URLs – Strengthen search engine rankings and simplify buyer navigation across multilingual storefronts with a single, consolidated URL structure. By extending the homepage's language URL segment consistently across catalog, product, brand, and search pages, and removing the duplicate segment previously seen on brand URLs, search engines can index pages cleanly under one URL structure per language. Turn on the Use Home Page Url Segment Across Catalog Pages setting (Catalog → URL Mapping) to apply this structure across catalog, product, brand, and search pages. This setting is enabled automatically for new websites, while existing websites keep their current structure to protect established indexing. See Translate URLs.
-
Polo Jimenez
commented
Based on this support ticket: https://support.optimizely.com/hc/en-us/requests/1804446, We’ve identified an issue with multilingual sites where the URLs returned by the api/v2/content/PageByUrl endpoint include an extra /fr/ segment.
Example:
English URL:
/brands/kalas/catalog/wire-and-cable/automotive-wire-and-cable
French URL returned by API:
/fr/brands/kalas/fr/catalog/wire-and-cable/automotive-wire-and-cableAs you can see, the fr segment is duplicated.
Translation Dictionary Configuration:
Catalog_UrlRoot = fr/catalog
Brand_UrlRoot = fr/brandsObserved behavior:
When navigating to a catalog under a brand, the system adds the language segment twice.Analysis:
We reviewed the source code and found that the issue seems to be in the PathBuilderUtilities.cs class, specifically in the GetCatalogRootPath method:var languageId = language?.Id ?? SiteContext.Current.LanguageDto?.Id;
This logic always builds the URL with the language prefix from the current SiteContext, which works correctly for standalone catalog pages. However, when the catalog is under a brand, another method has already appended the language segment. As a result, the language prefix (fr) is added again, causing the duplicated segment in the final URL.
Expected behavior:
The method should include a fallback or validation to check whether the language segment is already present in the URL before adding it again. Also, we'd like to customize this piece of code if you don't want to change it. Currently, it is not possible to customize it.Thanks,
Polo Jiménez