# SEO

What the platform writes into the head for every page, and what a theme should and should not add.

Search metadata is the platform's job, set by the merchant once for the whole store. A theme renders good markup and leaves the head to `content_for_header`.

## What the platform writes

`{{ content_for_header }}` contains, for every page:

- `<meta name="description">` - the SEO description of the object, or the store's template for that page type, or a short excerpt,
- `<link rel="canonical">` on the store's main domain, without sorting, filters or `?variant=` (lists keep `?page=`),
- `robots` - `noindex` for search results, the cart and anything the merchant hid,
- Open Graph tags - type, title, description, image, locale - and product price and availability on offer pages,
- the `<title>`: the platform **replaces the first `<title>` of your layout** with the title from the store's SEO templates.

Do not add your own description, canonical, robots or Open Graph tags - the page would have two.

## What the theme does

- **One `<h1>` per page** - the offer title, the category name, the page title. Block-level headings in sections are `<h2>` and below; the core `heading` block keeps `h1` for the page title.
- **Real links.** Products, categories and pagination are `<a href>`, not click handlers, so crawlers follow them.
- **Alternative text.** `alt` from `media.alt` for product pictures, empty `alt=""` for decorations.
- **Breadcrumbs** from `category.ancestors` - they help visitors and search engines.
- **Structured data where it describes what is on the page.** If you print Product or Review JSON-LD, its values must match what the visitor sees - the rating in `aggregateRating` must come from the reviews shown on that page. The core `faq` section has an option for FAQ structured data.
- **Lazy images below the fold, an eager one above it.** See [Performance](performance.md#images).

## Sitemaps and robots.txt

`/sitemap.xml` and `/robots.txt` of every store are generated by the platform from the published content and the merchant's SEO settings. A theme has no files for them.
