Ebnul
Ebnul

Reputation: 1

How can I dynamically set SEO titles and descriptions for my Shopify products

I want to set all my products titles to be like {Product_titles | Store Name}. How can I set that? The issue I'm seeing is that the products already have some manually put SEO titles, as we have added lots of products recently we want a single formula for all products SEO titles and meta descriptions. The template already has this dynamic code for titles

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

and for meta description

{%- if page_description -%}
      <meta name="description" content="{{ page_description | escape }}">

I want to keep different types of titles and meta descriptions for products, collections, pages and blog posts.

Can I edit them in shopify theme.liquid or is there any app that can help us in this?

Upvotes: 0

Views: 1550

Answers (1)

JMKelley
JMKelley

Reputation: 658

To dynamically change title's on the Product page only.

Find your <title></title> tags in your theme.

Add an {% if %} statement in there. Like so:

<title>{% if template == "product" %}Hey I'm a product page{% endif %}</title>

You can have quite a few if statements within the title tag.

In your case: <title>{% if template == "product" %}{{ product.title }} | {{ shop.name }}{% endif %}</title>

Upvotes: 1

Related Questions