All things Shopify and commerce
@malalta I noticed that my product page titles and meta have started showing up Unicode. I am not able to get to rid of it. Could you please guide.
Please find below template code biding used that is generating these titles and meta tags.
Meta:
Solved! Go to the solution
This is an accepted solution.
The problem here is that your text is getting double escaped.
Quick solution: it appears that Shopify auto escape the <title> (and maybe <meta> description?) tags automatically, so try removing the escape filter from your title and meta tags. Ie.
<!-- Change this: -->
<title>{{ my_title | escape }}</title>
<meta name="description" content="{{ my_meta_description | escape }}">
<!-- To this: -->
<title>{{ my_title }}</title>
<meta name="description" content="{{ my_meta_description }}">
————
You may already know this, but escaping is when the templating engine replaces certain characters in your text that may be problematic if they were rendered to HTML as is. For example if {{ my_title_text }} was "Weird </title> text - don't do this" and you put this in your .liquid file:
<title>{{ my_title_text }}</title>
..then without escaping you'd get this as your rendered HTML:
<title>Weird </title> text - don't do this</title>
...and your title would be "Weird "
————
Disclaimer(!) Try the above and check how your pages & html look. I couldn't find any documentation from Shopify on the auto escaping of <title> tags, other than this GitHib issue from 2013.
It would be great if someone from Shopify could confirm/deny this behaviour (and any other HTML tags that get special treatment), or point me to the documentation I've overlooked (entirely possible).
In case the <meta name="description"> tags aren't getting auto escaped and your layout breaks when removing the escape filter as above, try using the strip_html filter instead of escape:
<!-- Use the strip_html filter: -->
<meta name="description" content="{{ my_meta_description | strip_html }}">
This filter will just remove whole tags leaving the text unchanged, which will probably work better for your use case.
Hope that helps!
This is an accepted solution.
The problem here is that your text is getting double escaped.
Quick solution: it appears that Shopify auto escape the <title> (and maybe <meta> description?) tags automatically, so try removing the escape filter from your title and meta tags. Ie.
<!-- Change this: -->
<title>{{ my_title | escape }}</title>
<meta name="description" content="{{ my_meta_description | escape }}">
<!-- To this: -->
<title>{{ my_title }}</title>
<meta name="description" content="{{ my_meta_description }}">
————
You may already know this, but escaping is when the templating engine replaces certain characters in your text that may be problematic if they were rendered to HTML as is. For example if {{ my_title_text }} was "Weird </title> text - don't do this" and you put this in your .liquid file:
<title>{{ my_title_text }}</title>
..then without escaping you'd get this as your rendered HTML:
<title>Weird </title> text - don't do this</title>
...and your title would be "Weird "
————
Disclaimer(!) Try the above and check how your pages & html look. I couldn't find any documentation from Shopify on the auto escaping of <title> tags, other than this GitHib issue from 2013.
It would be great if someone from Shopify could confirm/deny this behaviour (and any other HTML tags that get special treatment), or point me to the documentation I've overlooked (entirely possible).
In case the <meta name="description"> tags aren't getting auto escaped and your layout breaks when removing the escape filter as above, try using the strip_html filter instead of escape:
<!-- Use the strip_html filter: -->
<meta name="description" content="{{ my_meta_description | strip_html }}">
This filter will just remove whole tags leaving the text unchanged, which will probably work better for your use case.
Hope that helps!
Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024Digital marketers and app developers have tracked activity in apps and websites for yea...
By Ollie Mar 13, 2024February was an exciting month with Shopify Editions, informative webinars, and more! F...
By JasonH Mar 7, 2024