Automatically add product title to SEO meta

Solved
earthtoplanet
Excursionist
31 5 3

Hello! I just moved my site to Shopify from Wordpress.org. On WP, when I created the title of a post it dynamically inputted that title into the SEO elements

I see with Shopify that you need to manually input the SEO content (Page Title, Description, URL). Is there a free way to make this process dynamic  so that when I input the product title it would automatically input the same title into the SEO fields? I would plan to use a template which mirrors the screenshot below.

 

earthtoplanet_0-1636521771515.png

If there is no solution for doing this with a dynamic variable or code tweak, I'm open to an app though am not looking to spend money on an SEO app at this moment.

Really appreciate the help!

Accepted Solutions (2)

Accepted Solutions
Niki_K
Shopify Partner
227 24 66

This is an accepted solution.

Hi @earthtoplanet,

no, it's my bad, I didn't explain it well. Sorry. Keep just product there as it is. 

I've tried it in my development store and it's working.

Try this:

 

 

{% if template contains 'product' %}
    	<title>{{ product.title | append: " | Earth To Planet Cartoons" | strip_html | escape }}</title>
{% else %}
    	<title>{{ page_title | append: " | Earth To Planet Cartoons" | escape }}</title>
{% endif %} 

 

Send me a link to your store to niki@hey.com and I'll help you out.
For more info what I do, visit nikikozak.me

View solution in original post

Niki_K
Shopify Partner
227 24 66

This is an accepted solution.

Hi @earthtoplanet,

1. Earth to Planet Cartoons is hardcoded, so I don't think that you can see it in the UI

2. Meta description

{% if template contains 'product' %}
      <meta name="description" content="This Earth To Planet cartoon is appropriately titled, {{ product.title | escape }}. Some will see it and laugh, others will become stark raving mad.">
{% else %}
      <meta name="description" content="{{ page_description | escape }}">
{% endif %}

 

I have two notes.

1. From SEO point of view, the meta descriptions could be seen as a duplicity. The only thing which changes is the product title, which isn't enough in my opinion.

2. Google has started overwriting titles and meta descriptions. This means that even if you write unique titles and meta descriptions for each product, it might happen that they will show up differently in SERP. I've put together information about this in one of my blog posts, if interested, here is a link: https://www.nikikozak.me/marketing/2021/07/25/titles-metadescriptions/

Hope this helps!

Send me a link to your store to niki@hey.com and I'll help you out.
For more info what I do, visit nikikozak.me

View solution in original post

Replies 6 (6)
Niki_K
Shopify Partner
227 24 66

Hi @earthtoplanet,

you'll need to edit the code. Go to your theme.liquid file and find the section with title. 

Remove the title tag and paste this: 

{% if template contains 'product' %}
    	<title>{{ product.title | strip_html | escape }}</title>
{% else %}
    	<title>{{ page_title | escape }}</title>
{% endif %} 

 

Since I don't know what theme you're using, I've written only if template contains 'product' – to be more specific, you can insert the name of the product file instead of just 'product' such as 'main-product'. This should be also working. 

Send me a link to your store to niki@hey.com and I'll help you out.
For more info what I do, visit nikikozak.me
earthtoplanet
Excursionist
31 5 3

Hi @Niki_K. Thanks for your help. I'm using the Minimal theme. 

I apologize, but I don't know what should be substituted in for 'product'

My goal is to have the same template for every product which inputs the product name and appends " | Earth To Planet Cartoons" so it would look like "Product Name | Earth To Planet Cartoons. I tried modifying your code but didn't do it correctly. Any ideas?

 

{% if template contains 'product' %}
    	<title>{{ product.title | strip_html | escape | append: " | Earth To Planet Cartoons"}}</title>
{% else %}
    	<title>{{ page_title | escape }}" | Earth To Planet Cartoons"</title>
{% endif %} 

  {% if page_description %}
  <meta name="description" content="{{ page_description | escape | append: " | Earth To Planet Cartoons"}}">
  {% endif %}

 

Niki_K
Shopify Partner
227 24 66

This is an accepted solution.

Hi @earthtoplanet,

no, it's my bad, I didn't explain it well. Sorry. Keep just product there as it is. 

I've tried it in my development store and it's working.

Try this:

 

 

{% if template contains 'product' %}
    	<title>{{ product.title | append: " | Earth To Planet Cartoons" | strip_html | escape }}</title>
{% else %}
    	<title>{{ page_title | append: " | Earth To Planet Cartoons" | escape }}</title>
{% endif %} 

 

Send me a link to your store to niki@hey.com and I'll help you out.
For more info what I do, visit nikikozak.me

View solution in original post

earthtoplanet
Excursionist
31 5 3

Awesome- thank you, @Niki_K 

  1. I created a test product and can see that the HTML header is now working: 

earthtoplanet_0-1636672214007.png

However, in the actual product creation page, it still shows as 

earthtoplanet_1-1636672249387.png

Is there an additional update I could make to have the UI accurately display the HTML Title?

Also, do you have the bandwidth to help me make a similar update for the HTML Description? The template I'm using is: This Earth To Planet cartoon is appropriately titled, "PRODUCT NAME". Some will see it and laugh, others will become stark raving mad.

Thank you for your help!

 

 

Niki_K
Shopify Partner
227 24 66

This is an accepted solution.

Hi @earthtoplanet,

1. Earth to Planet Cartoons is hardcoded, so I don't think that you can see it in the UI

2. Meta description

{% if template contains 'product' %}
      <meta name="description" content="This Earth To Planet cartoon is appropriately titled, {{ product.title | escape }}. Some will see it and laugh, others will become stark raving mad.">
{% else %}
      <meta name="description" content="{{ page_description | escape }}">
{% endif %}

 

I have two notes.

1. From SEO point of view, the meta descriptions could be seen as a duplicity. The only thing which changes is the product title, which isn't enough in my opinion.

2. Google has started overwriting titles and meta descriptions. This means that even if you write unique titles and meta descriptions for each product, it might happen that they will show up differently in SERP. I've put together information about this in one of my blog posts, if interested, here is a link: https://www.nikikozak.me/marketing/2021/07/25/titles-metadescriptions/

Hope this helps!

Send me a link to your store to niki@hey.com and I'll help you out.
For more info what I do, visit nikikozak.me

View solution in original post

earthtoplanet
Excursionist
31 5 3

Great! Thank you for the help and insight, @Niki_K.