skip to Main Content

I don’t know if I’m going about this the best way (hopefully I am), but I inserted the following code I found from a post on this website into my layout/theme.liquid file to make my product titles dynamic:

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

Mission accomplished. It worked just as I’d hoped. However, now my products are the only pages with titles. How can I edit the code so all the pages (not just the products) have appropriate titles for SEO?

2

Answers


  1. All you need is an else condition:

    <title>{% if template == "product" %}{{ product.title }} | {{ shop.name }}{% else %}{{ page_title }}{% endif %}</title>
    

    HTH

    Login or Signup to reply.
  2. Use the default liquid object to show the titles, you can check more about this here page_title

    enter image description here

    Also, you can check the reference code from theme.liquid file of the default dawn theme from Shopify itself
    Dawn theme

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search