datasn.io
datasn.io

Reputation: 12867

How to stop Shopify from truncating page titles in <title></title>?

I have several stores that I notice that Shopify seems to automatically truncate the product title longer than 65 or 70 in the <title></title>, before appending the store name.

For example, this product page.

The page title becomes:

<title>Boho Beach Lace Cap Sleeves Ivory Chiffon Wedding Flower Girl Dress wi - Flower Girl Dresses</title>

While it should be:

<title>Boho Beach Lace Cap Sleeves Ivory Chiffon Wedding Flower Girl Dress with Pink Lining - Flower Girl Dresses</title>

I know how Google doesn't care about titles longer than a certain amount of characters, e.g. 65 or 70 but still leaving whole keywords in there doesn't hurt.

For example in this case, if people search for "pink", it's still helpful to have a "pink" keyword in the title. I think it's definitely better to leave the title as is WITHOUT truncating it.

So how can I prevent Shopify from truncating the title?

I can only see this in theme.liquid:

<title>
{{ page_title }}{% if current_tags %}{% assign meta_tags = current_tags | join: ', ' %} - {{ 'general.meta.tags' | t: tags: meta_tags }}{% endif %}{% if current_page != 1 %} - {{ 'general.meta.page' | t: page: current_page }}{% endif %}{% unless page_title contains shop.name %} - {{ shop.name }}{% endunless %}
</title>

It doesn't strike as where I should modify to make this happen?

Upvotes: 1

Views: 576

Answers (1)

Rick Davies
Rick Davies

Reputation: 733

I don't believe it is truncated in the front-end Liquid. What you are seeing output is the page_title rather than the product.title. The former comes from the "SEO" section at the bottom of the product's admin page. By default that field is an apparently-truncated version of the product.title.

What you could do is something like this:

{% assign desiredTitle = page_title %}
{% if template == 'product' %}
  {% assign desiredTitle = product.title %}
{% endif %}
<title>
  {{ desiredTitle }} // etc. etc.
</title>

Upvotes: 2

Related Questions