Solved

Want to avoid Unicode in my titles and meta description of product pages.

Kashif91
Tourist
27 0 2

@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:

 
 {% for tag in collection.all_tags %}
 
 
  {% if current_tags contains "High Top Shoes" and collection.handle == "men-shoes" %}
  {% capture my_title %}Custom Print High Top Canvas Shoes for Men & Boys - The Funkydelic Store{% endcapture %}
    {% capture my_meta_description %}High-top sneakers for men come in a variety of design and patterns. Shop from almost endless array of high top canvas footwear prints to suit your fashion style.Express DHL Delivery Worldwide Shipping High Quality Prints Waterproof{% endcapture %}

  {% elsif current_tags contains "Low Top Shoes" and collection.handle == "men-shoes" %}
  {% capture my_title %}Custom Print Low Top Canvas Shoes for Men & Boys - The Funkydelic Store{% endcapture %}
    {% capture my_meta_description %}Low-top canvas sneakers for men are in vogue, no matter where you wear them. We, at The Funkydelic Store, offer you the freedom to create your very own custom low top shoes.Express DHL Delivery Worldwide Shipping High Quality Prints Waterproof{% endcapture %}

    {% elsif current_tags contains "Barefoot Shoes" and collection.handle == "men-shoes" %}
  {% capture my_title %}Custom Print Canvas Barefoot Shoes for Men & Boys - The Funkydelic Store{% endcapture %}
    {% capture my_meta_description %}Barefoot shoes for men have been designed to let you feel the ease of walking or running barefoot. These printed minimalist barefoot sneakers can be worn just anywhere you want. Wear your style & Shop wide range of barefoot designer shoes for men.Express DHL Delivery Worldwide Shipping High Quality Prints Waterproof{% endcapture %}

    {% elsif current_tags contains "Slip-on Shoes" and collection.handle == "men-shoes" %}
  {% capture my_title %}Custom Print Slip-on Shoes for Men & Boys - The Funkydelic Store{% endcapture %}
    {% capture my_meta_description %}A great pair of casual slip-on shoes is all you need to jazz up a plain look. TFS brings to you printed canvas slip-on sneakers for men & boys for all kinds of days & moods - slip-on shoes that can do so much more than provide comfort to your feet. Slide into one from our online platform. Express DHL Delivery Worldwide Shipping High Quality Print{% endcapture %}

    {% elsif current_tags contains "Boots" and collection.handle == "men-shoes" %}
  {% capture my_title %}Custom Print Canvas Boots for Men & Boys - The Funkydelic Store{% endcapture %}
    {% capture my_meta_description %}Our custom made canvas boots for men are designed to let you feel the ease of walking. Shop from a variety of prints available for men's boots at TFS. Express DHL Delivery Worldwide Shipping High Quality Prints Waterproof{% endcapture %}

    {% elsif current_tags contains "Sliders" and collection.handle == "men-shoes" %}
  {% capture my_title %}Custom Print Sliders for Men & Boys - The Funkydelic Store{% endcapture %}
    {% capture my_meta_description %}Check out our custom sliders collection for men from a wide variety of cool designs. Custom slider sandals from TFS are personalized for men of all style sensibilities, light weight & feels soft on feet. Express DHL Delivery Worldwide Shipping High Quality Prints Waterproof{% endcapture %}

 


 

    {% elsif current_tags contains "High Top Shoes" and collection.handle == "women-shoes" %}
  {% capture my_title %}Custom Print High Top Canvas Shoes for Women & Girls - The Funkydelic Store{% endcapture %}
    {% capture my_meta_description %}For women, high-top sneakers were the conventional comfort footwear to be worn with jeans or shorts! But with the advent of mix-n-match fashion, you can now flaunt a pair of sexy high-top canvas shoes for women with a breezy summer dress too. Whatever be your preference, there is a high-top shoe design right for it. Express DHL Delivery Worldwide Shipping High Quality Prints Waterproof{% endcapture %}

    {% elsif current_tags contains "Low Top Shoes" and collection.handle == "women-shoes" %}
  {% capture my_title %}Custom Print Low Top Canvas Shoes for Women & Girls - The Funkydelic Store{% endcapture %}
    {% capture my_meta_description %}Perfect epitome of grunge style & cool comfort, low-top sneakers for women have become the must-have accessory in every woman’s shoe cabinet. Shop the style of print you want & garner whiplashes for your shoe designs! Express DHL Worldwide Delivery High Quality Prints Waterproof{% endcapture %}

    {% elsif current_tags contains "Barefoot Shoes" and collection.handle == "women-shoes" %}
  {% capture my_title %}Custom Print Canvas Barefoot Shoes for Women & Girls - The Funkydelic Store{% endcapture %}
    {% capture my_meta_description %}Barefoot shoes for women have been designed to let you feel the ease of walking or running barefoot. These printed minimalist barefoot sneakers can be worn just anywhere you want. Wear your style & Shop wide range of barefoot designer shoes for women.Express DHL Delivery Worldwide Shipping High Quality Prints Waterproof{% endcapture %}

    {% elsif current_tags contains "Slip-on Shoes" and collection.handle == "women-shoes" %}
  {% capture my_title %}Custom Print Slip-on Shoes for Women & Girls - The Funkydelic Store{% endcapture %}
    {% capture my_meta_description %}A great pair of casual slip-on shoes is all you need to jazz up a plain look. TFS brings to you printed canvas slip-on sneakers for women & girls for all kinds of days & moods - slip-on shoes that can do so much more than provide comfort to your feet. Slide into one from our online platform. Express DHL Delivery Worldwide Shipping High Quality Prints Waterproof{% endcapture %}

    {% elsif current_tags contains "High Heel Ankle Boots" and collection.handle == "women-shoes" %}
  {% capture my_title %}Custom Print High Heels Ankle Boots for Women & Girls - The Funkydelic Store{% endcapture %}
    {% capture my_meta_description %}For lovers of high heels, there is nothing more powerful than donning a pair of designer high heel shoes or sneakers. At TFS, we create unique designer high heel ankle boots that cater to women & girls of all style sensibilities. Express DHL Delivery Worldwide Shipping High Quality Prints Waterproof{% endcapture %}

    {% elsif current_tags contains "Boots" and collection.handle == "women-shoes" %}
  {% capture my_title %}Custom Print Canvas Boots for Men & Boys - The Funkydelic Store{% endcapture %}
    {% capture my_meta_description %}Our custom made canvas boots for women are designed to let you feel the ease of walking. Shop from a variety of prints available for women's boots at TFS. Express DHL Delivery Worldwide Shipping High Quality Prints Waterproof{% endcapture %}

    {% elsif current_tags contains "Sliders" and collection.handle == "women-shoes" %}
  {% capture my_title %}Custom Print Sliders for Women & Girls - The Funkydelic Store{% endcapture %}
    {% capture my_meta_description %}Check out our custom sliders collection for women from a wide variety of cool designs. Custom slider sandals from TFS are personalized for women of all style sensibilities, light weight & feels soft on feet. Express DHL Delivery Worldwide Shipping High Quality Prints Waterproof{% endcapture %}



    {% elsif current_tags contains "High Top Shoes" and collection.handle == "kids-shoes" %}
  {% capture my_title %}Custom Print High Top Canvas Shoes for Kids & Young Boys - The Funkydelic Store{% endcapture %}
    {% capture my_meta_description %}The comfort of high-top kids shoes from TFS is undeniable; it lets them run around unhindered, without a care in the world. Shop from almost endless array of high top canvas sneaker prints to suit your fashion style.Express DHL Delivery Worldwide Shipping High Quality Prints{% endcapture %}

    {% elsif current_tags contains "Low Top Shoes" and collection.handle == "kids-shoes" %}
  {% capture my_title %}Custom Print Low Top Canvas Shoes for Kids & Young Boys - The Funkydelic Store{% endcapture %}
    {% capture my_meta_description %}The comfort of low top canvas shoes for kids from TFS is undeniable; it lets them run around unhindered, without a care in the world. Shop from almost endless array of high top canvas sneaker prints to suit your fashion style.Express DHL Delivery Worldwide Shipping High Quality Prints{% endcapture %}

    {% elsif current_tags contains "Slip-on Shoes" and collection.handle == "kids-shoes" %}
  {% capture my_title %}Custom Print Slip-on Shoes for Kids & Young Boys - The Funkydelic Store{% endcapture %}
    {% capture my_meta_description %}A great pair of casual slip-on shoes for kids is all you need to jazz up your child's cute look. TFS brings to you printed canvas slip-on sneakers for children for all kinds of days & moods - slip-on shoes that can do so much more than provide comfort to your child's feet. Slide into one from our online platform. Express DHL Delivery Worldwide Shipping High Quality Prints{% endcapture %}

    {% elsif current_tags contains "Barefoot Shoes" and collection.handle == "kids-shoes" %}
  {% capture my_title %}Custom Print Canvas Barefoot Shoes for Kids & Young Boys - The Funkydelic Store{% endcapture %}
    {% capture my_meta_description %}Barefoot shoes for kids from TFS have been designed to protect delicate feet from a tender age. These printed minimalist barefoot sneakers can be worn just anywhere you want. Shop from a wide range of best barefoot shoes designs Express DHL Delivery Worldwide Shipping High Quality Prints{% endcapture %}

    {% elsif current_tags contains "Sneakers" and collection.handle == "kids-shoes" %}
  {% capture my_title %}Custom Print Sneakers for Kids up to 12 years - The Funkydelic Store{% endcapture %}
    {% capture my_meta_description %}Custom sneakers for kids (3-12 years) from TFS come in a variety of cute, adorable, colorful patterns. In case you are looking for something unique for your children, do check out our sneaker collection for kids. Express DHL Delivery Worldwide Shipping High Quality Prints Waterproof{% endcapture %}


 
 
  {% elsif page_description %}
 
  {% capture my_title %}{% if template == 'index' %}{% if page_title contains 'Welcome' %}{{ shop.name }} – Welcome{% else %}{{ page_title }}{% endif %}{% elsif template == '404' %}Page Not Found{% elsif page_title contains shop.name %}{{ page_title }}{% else %}{{ page_title }} – {{ shop.name }}{% endif %}{% endcapture %}
    {% capture my_meta_description %}{{ page_description }}{% endcapture %}
 
  {% endif %}
 
  {% endfor %}

  {% if my_meta_description %}
  <title>
    {{ my_title | escape }}
  </title>
  <meta name="description" content="{{ my_meta_description | escape }}">
 
  {% elsif page_description %}
   <title>
    {% if template == 'index' %}
    {% if page_title contains 'Welcome' %}{{ shop.name }} &ndash; Welcome{% else %}{{ page_title }}{% endif %}{% elsif template == '404' %}Page Not Found{% elsif page_title contains shop.name %}{{ page_title }}{% else %}{{ page_title }} &ndash; {{ shop.name }}
    {% endif %}
  </title>
  {% if page_description %}
  <meta name="description" content="{{ page_description }}" />
  {% endif %}
 
  {% endif %}
 
Tittle
 
{% for tag in collection.all_tags %}
 
 
  {% if current_tags contains "High Top Shoes" and collection.handle == "men-shoes" %}
  {% capture my_h1  %}Men High Top Shoes{% endcapture %}
     
    {% elsif current_tags contains "Low Top Shoes" and collection.handle == "men-shoes" %}
  {% capture my_h1  %}Men Low Top Shoes{% endcapture %}
     
    {% elsif current_tags contains "Barefoot Shoes" and collection.handle == "men-shoes" %}
  {% capture my_h1  %}Men Barefoot Shoes{% endcapture %}
     
    {% elsif current_tags contains "Slip-on Shoes" and collection.handle == "men-shoes" %}
  {% capture my_h1  %}Men Slip-on Shoes{% endcapture %}
   
      {% elsif current_tags contains "boots" and collection.handle == "men-shoes" %}
  {% capture my_h1  %}Men Boots{% endcapture %}
     
      {% elsif current_tags contains "Sliders" and collection.handle == "men-shoes" %}
  {% capture my_h1  %}Men Sliders{% endcapture %}
     
     
     
     
     
      {% elsif current_tags contains "High Top Shoes" and collection.handle == "women-shoes" %}
        {% capture my_h1  %}Women High Top Shoes{% endcapture %}
     
        {% elsif current_tags contains "Low Top Shoes" and collection.handle == "women-shoes" %}
        {% capture my_h1  %}Women Low Top Shoes{% endcapture %}
     
        {% elsif current_tags contains "Barefoot Shoes" and collection.handle == "women-shoes" %}
        {% capture my_h1  %}Women Barefoot Shoes{% endcapture %}
     
        {% elsif current_tags contains "Slip-on Shoes" and collection.handle == "women-shoes" %}
        {% capture my_h1  %}Women Slip-on Shoes{% endcapture %}
     
        {% elsif current_tags contains "High Heel Ankle Boots" and collection.handle == "women-shoes" %}
        {% capture my_h1  %}Women High Heel Ankle Boots{% endcapture %}
     
        {% elsif current_tags contains "boots" and collection.handle == "women-shoes" %}
        {% capture my_h1  %}Women Boots{% endcapture %}
     
        {% elsif current_tags contains "Sliders" and collection.handle == "women-shoes" %}
        {% capture my_h1  %}Women Sliders {% endcapture %}
     
     
     
     
      {% elsif current_tags contains "High Top Shoes" and collection.handle == "kids-shoes" %}
        {% capture my_h1  %}Kids High Top Shoes{% endcapture %}
     
        {% elsif current_tags contains "Low Top Shoes" and collection.handle == "kids-shoes" %}
        {% capture my_h1  %}Kids Low Top Shoes{% endcapture %}
     
        {% elsif current_tags contains "Slip-on Shoes" and collection.handle == "kids-shoes" %}
        {% capture my_h1  %}Kids Slip-on Shoes{% endcapture %}
     
        {% elsif current_tags contains "Barefoot Shoes" and collection.handle == "kids-shoes" %}
        {% capture my_h1  %}Kids Barefoot Shoes{% endcapture %}
     
        {% elsif current_tags contains "Sneakers" and collection.handle == "kids-shoes" %}
        {% capture my_h1  %}Kids Sneakers{% endcapture %}
     
 
  {% elsif collection.title %}
  {% capture my_h1 %}{{ collection.title }}{% endcapture %}
 
  {% endif %}
 
  {% endfor %}
     
  {% if my_h1 %}
  <h1>{{ my_h1 }}</h1>
  {% elsif collection.title %}
<h1>{{ collection.title }}</h1>
  {% endif %}
  
Please help in resolving the unicode issue
 
Thanks
Accepted Solution (1)

malalta
Shopify Partner
23 5 15

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!

View solution in original post

Replies 3 (3)

malalta
Shopify Partner
23 5 15

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!

Kashif91
Tourist
27 0 2

@malalta let me try this and see if it works. Thanks a ton!

Kashif91
Tourist
27 0 2

@malalta Thanks so much for your help. It worked!