> For the complete documentation index, see [llms.txt](https://mac-eth.gitbook.io/macs-web-dev-sop/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mac-eth.gitbook.io/macs-web-dev-sop/seo/metadata.md).

# 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 [title tag](https://shopify.dev/docs/themes/seo/metadata#the-title-tag)
* The [meta description](https://shopify.dev/docs/themes/seo/metadata#the-meta-description)
* [Canonical URLs](https://shopify.dev/docs/themes/seo/metadata#canonical-urls)

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

For example:

{% code title="layouts/theme.liquid" %}

```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>
```

{% endcode %}

{% hint style="info" %}
For another example of including metadata in a theme, you can refer to [Dawn's implementation](https://github.com/Shopify/dawn/blob/main/layout/theme.liquid).
{% endhint %}

#### The title tag <a href="#the-title-tag" id="the-title-tag"></a>

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](https://shopify.dev/docs/api/liquid/objects/page_title).

#### The meta description <a href="#the-meta-description" id="the-meta-description"></a>

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](https://shopify.dev/docs/api/liquid/objects/page_description).

#### Canonical URLs <a href="#canonical-urls" id="canonical-urls"></a>

You can specify a canonical URL for a given page using the global Liquid [canonical\_url object](https://shopify.dev/docs/api/liquid/objects/canonical_url).
