Re: Locale Aware URLs in Product Descriptions

Locale Aware URLs in Product Descriptions

StephenK
Shopify Partner
80 7 46

I've recently updated a theme for a client using Markets to change all URLs to locale aware ones instead of hardcoded ones.

However I can't find a way to do this with links within areas like Product Description text, has anyone come up with a solution there?

I had thought about using JS to check through anchor tags in the description html and add the locale code if needed, but seems a bit of a hacky solution.

Some Shopify/Ecommerce related articles - https://medium.com/@stephenkeable
Replies 2 (2)

matt-cos
Shopify Partner
2 0 0

Hey @StephenK!

 

Not sure if you're still looking for an answer here, but incase anyone else comes across this post, you can just use relative links in the product description.

 

As an example, instead of "https://store.com/products/name", use "/products/name". Shopify will automatically convert them to the correct market.

StephenK
Shopify Partner
80 7 46

Not including the "market code" (ie en-GB) in the url causes the user to be bounced back to the default detected market. Which if someone is overseas (say in fr-FR), but has manually changed the market to their home one (en-GB) and clicks a URL without the code in, it will default back to (fr-FR).

Some Shopify/Ecommerce related articles - https://medium.com/@stephenkeable