Metadata

Add SEO metadata to your theme

You can include search engine optimization (SEO) metadata in your theme using HTML and Liquid. There are three main aspects to consider:

The code for the above SEO metadata should be included in the <head> element.

For example:

layouts/theme.liquid
<head>
  <title>
    {{ page_title -}}
    {%- if current_tags %} &ndash; tagged "{{ current_tags | join: ', ' }}"{% endif -%}
    {%- if current_page != 1 %} &ndash; Page {{ current_page }}{% endif -%}
    {%- unless page_title contains shop.name %} &ndash; {{ shop.name }}{% endunless -%}
  </title>

  {% if page_description %}
    <meta name="description" content="{{ page_description | escape }}" />
  {% endif %}

  <link rel="canonical" href="{{ canonical_url }}" />
</head>

For another example of including metadata in a theme, you can refer to Dawn's implementation.

The title tag

You can include a <title> element for search engines to read the page title from. The title for most pages can be set in the admin, and you can access this title with the Liquid page_title object.

The meta description

You can include a <meta> element for search engines to read the page description from. The description for most pages can be set in the admin, and you can access this description with the Liquid page_description object.

Canonical URLs

You can specify a canonical URL for a given page using the global Liquid canonical_url object.

Last updated