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

Shopify: How To Program Dynamic Theme Titles and Meta Descriptions for search engine optimisation utilizing Liquid


For those who’ve been studying my articles over the previous few 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 personalized 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 centered on is search engine marketing. Over time, we imagine that natural search would be the lowest value per acquisition and consumers with the very best intent to buy. In our analysis, we recognized that ladies store for clothes with 5 key determination influencers:

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

Titles and meta descriptions are essential at getting your content material listed and displayed correctly. So, in fact, 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 end result pages (SERPs) that present extra info that entices the search consumer to click on by.

The problem is that Shopify usually shares titles and meta descriptions throughout completely different web page templates – dwelling, collections, merchandise, and so on. 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 all the particulars of the syntax, however you possibly can dynamically generate a web page title fairly simply. One factor you could have to bear in mind right here is that merchandise have variants … so incorporating variants into your web page title implies that it’s important to loop by 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 at this time for $78.00 » Multi Knee-Size » Closet52</title>

And right here’s the code that produces that end result:

{%- seize seo_title -%}
    {%- if template == "assortment" -%}{{ "Order " }}{%- endif -%}
    {{- page_title -}}
    {%- if template == "assortment" -%}{{ " On-line" }}{%- endif -%}
    {% assign my_separator = " » " %}
    {%- if current_tags -%} be a part of: ', ' -%
      {%- if template == 'weblog' -%} 
      {{ " Articles" }} {%- if current_tags -%}{ capitalize }{%- 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.title == 'Shade' %}{ be a 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 Delivery, No-Trouble Returns{% endif %}{{ my_separator }}{{ store.title }}
  {%- 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 by the colour choices and construct a comma-separated string.
  • Metafields – this Shopify occasion has the costume size as a metafield that we want to embody.
  • Value – embody the primary variant’s worth.
  • Store Title – add the store’s title on the finish of the title.
  • Separator – quite than repeating the separator, we simply make it a string project and repeat it. That means, if we determine to vary that image sooner or later, it’s solely in a single place.

Optimize Your Shopify Web page Meta Description

After we crawled the positioning, we observed that any theme template web page that was referred to as was repeating the house web page search engine optimisation 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.

For those who’re undecided what your template title is, simply add an HTML be aware in your theme.liquid file and you’ll 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 might 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 title="description" content material="Flip heads on this basic hunter inexperienced plaid sweater costume. Fashionable updates make it vital: the stand-up neckline, three-quarter sleeves and the right size. On sale at this time for $78.00! All the time FREE 2-day transport and no-hassle returns at Closet52.">

Right here’s that code:

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

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

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

By the way in which, when 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 Attire 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. For those who’d like help in growing your ecommerce presence utilizing Shopify, please contact us.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments