How are handles computed?

Highlighted
Shopify Partner
11 1 0

How EXACTLY does Shopify compute handles for products and other objects??

This page - https://shopify.dev/docs/themes/liquid/reference/basics/handle - says, "By default, a handle is the object's title in lowercase with any spaces and special characters replaced by hyphens (-)." However, I have not found that to be the whole story.

I did some tests, and looked through the community posts, and there seem to be other rules in effect:

  • Multiple spaces are reduced to a single hyphen
  • Resulting multiple hyphens are reduced to a single hyphen
  • Characters such as € and £ are converted to hyphens
  • Characters such as ® and ™ and ồ (as in Hồng) are preserved
  • Accented characters such as á and ö are converted to non-accent versions such as a and o
  • œ was converted to oe

Example:

Original string: Example/Sample ö and ™ or ® and Hồng but not £ or € and--also á and ö are converted to a and o, also œ is converted
Resulting Handle: example-sample-o-and-™-or-®-and-hồng-but-not-or-and-also-a-and-o-are-converted-to-a-and-o-also-oe-is-converted

Could someone at Shopify post the actual algorithm (or code) that computes handles?

Thanks,

 -djs

0 Likes
Highlighted
Shopify Partner
279 29 55

following

If helpful then please Like and Accept Solution.
Email: suhagiyajivan1992@gmail.com
Skype: jivan.suhagiya
Give a try to Shopify APP: https://apps.shopify.com/short-track
0 Likes
Highlighted
Shopify Partner
11 1 0

+1

[Reply corrected. I misunderstood

0 Likes
Highlighted
Shopify Partner
279 29 55

Hi David,

I think you misunderstood my comment! I'm also looking for same algo so I'm following your post

If helpful then please Like and Accept Solution.
Email: suhagiyajivan1992@gmail.com
Skype: jivan.suhagiya
Give a try to Shopify APP: https://apps.shopify.com/short-track
0 Likes