What's your biggest current challenge? Have your say in Community Polls along the right column.

Re: Locale Aware URLs in Product Descriptions

Locale Aware URLs in Product Descriptions

StephenK
Shopify Partner
81 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 4 (4)

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
81 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
mmarcus15
Shopify Partner
15 0 1

@StephenK Did you ever find a fix for this? I'm having the same issue. Even when I just have this as the href "/products/name", it still takes the person back to the root URL, instead of the market they are in (where the root could be "/en-ca/products/name")

StephenK
Shopify Partner
81 7 46

No, and I no longer deal with Shopify store development on a day to day basis.

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