Wednesday, July 20, 2022
Google search engine
HomeMobile MarketingShopify: How To Program Dynamic Theme Titles and Meta Descriptions for website...

Shopify: How To Program Dynamic Theme Titles and Meta Descriptions for website positioning utilizing Liquid


If you happen to’ve been studying my articles over the previous couple of months, you’ll discover that I’ve been sharing much more about ecommerce, particularly with regard to Shopify. My agency has been constructing out a extremely custom-made and built-in Shopify Plus web site for a shopper. Somewhat than spending months and tens of hundreds of {dollars} on constructing a theme from scratch, we talked the shopper into permitting us to make use of a well-built and supported theme that was tried and examined. We went with Wokiee, a multipurpose Shopify Theme that has a ton of capabilities.

It nonetheless required months of growth to include the pliability we wanted based mostly on market analysis and our shopper’s suggestions. On the core of the implementation was that Closet52 is a direct-to-consumer ecommerce web site the place girls would have the ability to simply purchase clothes on-line.

As a result of Wokiee is a multipurpose theme, one space we’re extremely targeted on is search engine marketing. Over time, we consider that natural search would be the lowest value per acquisition and buyers with the best intent to buy. In our analysis, we recognized that girls store for clothes with 5 key choice influencers:

  • Types of clothes
  • Colours of clothes
  • Costs of clothes
  • Free Transport
  • No-hassle Returns

Titles and meta descriptions are essential at getting your content material listed and displayed correctly. So, after all, we would like a title tag and meta descriptions which have these key components!

  • The title tag in your web page heading is essential to make sure your pages are listed correctly for the searches of relevance.
  • The meta description is displayed in search engine outcome pages (SERPs) that present extra info that entices the search consumer to click on via.

The problem is that Shopify typically shares titles and meta descriptions throughout totally different web page templates – dwelling, collections, merchandise, and so forth. So, I needed to write some logic to dynamically populate the titles and meta descriptions correctly.

Optimize Your Shopify Web page Title

Shopify’s theme language is liquid and it’s fairly good. I received’t get into the entire particulars of the syntax, however you possibly can dynamically generate a web page title fairly simply. One factor you’ve to bear in mind right here is that merchandise have variants … so incorporating variants into your web page title implies that you need to loop via the choices and dynamically construct the string when the template is a product template.

Right here’s an instance of a title for a plaid sweater costume.

<title>Plaid Sweater Gown on sale right this moment for $78.00 » Multi Knee-Size » Closet52</title>

And right here’s the code that produces that outcome:

{%- seize seo_title -%}
    {%- if template == "assortment" -%}{{ "Order " }}{%- endif -%}
    {{- page_title -}}
    {%- if template == "assortment" -%}{{ " On-line" }}{%- endif -%}
    {% assign my_separator = " » " %}
    {%- if current_tags -%} be part of: ', ' -%
      {%- if template == 'weblog' -%} 
      {{ " Articles" }} {%- if current_tags -%}{ t: tags: meta_tags }{%- endif -%}
      {%- else -%}
      {{ my_separator }}{ t: tags: meta_tags -}
      {%- endif -%}
    {%- endif -%}
    {%- if current_page != 1 -%}{{ my_separator }}{ t: web page: current_page }{%- endif -%}
    {%- if template == "product" -%}{{ " solely " }}{ cash }{{ my_separator }}{% for product_option in product.options_with_values %}{% if product_option.identify == 'Shade' %}{ be part of: ', ' }{% endif %}{% endfor %}{% if product.metafields.my_fields.dress_length != clean %} {{ product.metafields.my_fields.dress_length }}{%- endif -%}{%- endif -%}
    {% if template == "assortment" %}{{ my_separator }}Free Transport, No-Problem Returns{% endif %}{{ my_separator }}{{ store.identify }}
  {%- endcapture -%}

<title>{ strip_newlines }</title>

The code breaks down like this:

  • Web page Title – incorporate the precise web page title first… whatever the template.
  • Tags – incorporate tags by becoming a member of tags related to a web page.
  • Product Colours – loop via the colour choices and construct a comma-separated string.
  • Metafields – this Shopify occasion has the costume size as a metafield that we want to embrace.
  • Value – embrace the primary variant’s value.
  • Store Title – add the store’s identify on the finish of the title.
  • Separator – reasonably than repeating the separator, we simply make it a string project and repeat it. That approach, if we resolve to vary that image sooner or later, it’s solely in a single place.

Optimize Your Shopify Web page Meta Description

Once we crawled the positioning, we observed that any theme template web page that was referred to as was repeating the house web page website positioning settings. We needed so as to add a unique meta description relying on whether or not the web page was a house web page, collections web page, or precise product web page.

If you happen to’re unsure what your template identify is, simply add an HTML be aware in your theme.liquid file and you may view the supply of the web page to determine it.

<!-- Template: {{ template }} -->

This allowed us to determine all of the templates that used the positioning’s meta description in order that we may modify the meta description based mostly on the template.

Right here’s the meta description we would like on the above product web page:

<meta identify="description" content material="Flip heads on this basic hunter inexperienced plaid sweater costume. Fashionable updates make it a must have: the stand-up neckline, three-quarter sleeves and the right size. On sale right this moment for $78.00! All the time FREE 2-day delivery and no-hassle returns at Closet52.">

Right here’s that code:

  {%- seize seo_metadesc -%}
  	{%- if page_description -%}
  	  {%- if template == 'list-collections' -%}
  			{ strip }
      {%- else -%}
          { escape -} 
          {%- if template == 'weblog' -%}
          {{ " Listed here are our articles" }} {%- if current_tags -%}{ downcase }{%- endif -%}.
          {%- endif -%}
          {%- if template == 'product' -%}
  			{{ " Solely " }}{ cash }!
  		  {%- endif -%}
      {%- endif -%}   	
  	{%- endif -%}
    {%- if template == 'assortment' -%}
            { strip }
    {%- endif -%}
    {{ " All the time FREE 2-day delivery and no-hassle returns at " }}{ strip }.
  {%- endcapture -%}

<meta identify="description" content material="{ strip_newlines }">

The result’s a dynamic, complete set of titles and meta descriptions for any kind of template or the detailed product web page. Transferring ahead, I’ll most definitely refactor the code utilizing case statements and arrange it slightly higher. However for now, it’s producing a a lot nicer presence in search engine outcome pages.

By the way in which, in case you’d like an excellent low cost… we’d love you to check out the positioning with a 30% off coupon, use code HIGHBRIDGE when trying out.

Store For Clothes Now

Disclosure: I’m an affiliate for Shopify and Themeforest and I’m utilizing these hyperlinks on this article. Closet52 is a shopper of my agency, Highbridge. If you happen to’d like help in creating your ecommerce presence utilizing Shopify, please contact us.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments