Wednesday, July 20, 2022
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 website for a shopper. Fairly 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 improvement 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 website the place girls would have the ability to simply purchase attire on-line.

As a result of Wokiee is a multipurpose theme, one space we’re extremely centered on is SEO. Over time, we consider that natural search would be the lowest price per acquisition and consumers with the very best intent to buy. In our analysis, we recognized that ladies store for attire with 5 key resolution influencers:

  • Types of attire
  • Colours of attire
  • Costs of attire
  • 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 parts!

  • 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 consequence 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 totally different web page templates – house, 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 gained’t get into all the particulars of the syntax, however you may dynamically generate a web page title fairly simply. One factor you may have to remember right here is that merchandise have variants … so incorporating variants into your web page title signifies that you need 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 present for $78.00 » Multi Knee-Size » Closet52</title>

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

{%- 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 == 'Colour' %}{ 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-Problem 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 embrace.
  • Value – embrace the primary variant’s value.
  • Store Title – add the store’s title on the finish of the title.
  • Separator – slightly than repeating the separator, we simply make it a string task 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 location, we observed that any theme template web page that was referred to as was repeating the house web page website positioning settings. We wished so as to add a distinct 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 title is, simply add an HTML word in your theme.liquid file and you may view the supply of the web page to establish it.

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

This allowed us to establish all of the templates that used the location’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 title="description" content material="Flip heads on this basic hunter inexperienced plaid sweater costume. Fashionable updates make it essential: the stand-up neckline, three-quarter sleeves and the right size. On sale at present for $78.00! At all times 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 -%}{ downcase }{%- endif -%}.
          {%- endif -%}
          {%- if template == 'product' -%}
  			{{ " Solely " }}{ cash }!
  		  {%- endif -%}
      {%- endif -%}   	
  	{%- endif -%}
    {%- if template == 'assortment' -%}
            { strip }
    {%- endif -%}
    {{ " At all times 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. Shifting ahead, I’ll almost definitely refactor the code utilizing case statements and manage it somewhat higher. However for now, it’s producing a a lot nicer presence in search engine consequence pages.

By the way in which, in the event you’d like an amazing low cost… we’d love you to check out the location 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. If you happen to’d like help in growing your ecommerce presence utilizing Shopify, please contact us.



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments