Using liquid code in Plug in SEO Plus

Plug in SEO Plus Liquid is very similar to Shopify Liquid, giving you access to lots of Liquid objects and filters to use in your SEO.

In this article

 


 

Basics

As a really simple example, let's say we want get the name of the product.

We would use the Liquid object product.title to do this. We surround the object with %% to indicate it is an object:

Input

%% product.title %%

Output

Laughing man t-shirt

Templates can of course contain static text too. Say we want to add ' - Stock Photo T-shirts' to the end. In the template we'll just write this text in without surrounding it with %%:

Input

%% product.title %% - Stock Photo T-shirts

Output

Laughing man t-shirt - Stock Photo T-shirts

Liquid filters let us manipulate objects it lots of different ways. We add filters to an object using ||. For example, if we want to remove 't-shirt' from the product.title we can use the remove filter:

Input

%% product.title || remove: ' t-shirt' %% - Stock Photo T-shirts

Output

Laughing man - Stock Photo T-shirts

We can add as many filters as we like, separating each with ||:

Input

%% product.title || remove: ' t-shirt' || upcase %% - Stock Photo T-shirts

Output

LAUGHING MAN - Stock Photo T-shirts

 


 

Plug in SEO Plus Liquid vs. Shopify Liquid

Plug in SEO Plus Liquid is very similar to Shopify Liquid, giving you full access to a wide range of objects and filters to use in your SEO.

There are a couple of differences.

  Shopify Liquid Plug in SEO Plus Liquid
Parenthesis

{{ product.title }}

%% product.title %%
Filters

{{ product.title | append: 'Buy' }}

%% product.title || append: 'Buy' %%
Filter parameters

{{ product.title | append: 'Buy' }}

{{ product.title | truncate: 100 }}

single quotes can be left out for numbers / truthy

%% product.title || append: 'Buy' %%

%% product.title || truncate: '100' %%

single quotes required for every parameter, including numbers / truthy

Whitespace

{{   product.title|append:   'Buy' | truncate:100}}

tolerant of whitespace

%% product.title || append: 'Buy' || truncate: '100' %%

whitespace must be exactly one space around parenthesis, filters and parameters

Filters   All Array, HTML, Math, Money, String and Additional filters are supported where there are zero or one parameters
Objects   All Liquid objects where the reference is between 0-3 levels deep like object, object.variable, object.variable1.variable2, and object.variable1.variable2.variable3

 


 

Additional filters

We've added these filters.


prepend_not_empty

Prepends a string only if the object is not empty. If the object is empty, the string will not be prepended.

Input

%% current_tags || join: ', ' || prepend_not_empty: 'Buy ' %% Stock Photo Tees

Output

current_tags is empty

Stock Photo Tees

current_tags is not empty

Buy black, blue Stock Photo Tees

append_not_empty

Appends a string only if the object is not empty. If the object is empty, the string will not be appended.

Input

%% current_tags || join: ', ' || append_not_empty: ' t-shirts from' %% Stock Photo Tees

Output

current_tags is empty

Stock Photo Tees

current_tags is not empty

black, blue t-shirts from Stock Photo Tees

take

Takes the first X items from an array.

Input

%% collection.all_tags || take: '3' || join: ', ' %%

Output

black, blue, green

 


 

Where you can use Liquid

  • Title and Description templates for Collections / Products / Pages / Blogs / Articles (this also lets you accomplish things like unique titles for collections filtered by tags/types/vendors that isn't possible without templating)
  • Default Title and Description
  • Homepage, Search, 404 special pages Title and Description
  • Titles and Descriptions manually entered in your Shopify admin 'Edit SEO' section
  • Bulk editing of Titles and Descriptions in your Shopify admin
  • Title Appender
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us