# 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).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mac-eth.gitbook.io/macs-web-dev-sop/seo/metadata.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
