# Sanity image SEO

> Add an alt text field to Sanity images, keep hotspot and crop working, and serve sized, modern-format images with the image URL parameters.

Canonical: https://scaplet.com/seo/sanity/image-seo

Guide Sanity Sanity · Images

Add an alt text field to Sanity images, keep hotspot and crop working, and serve sized, modern-format images with the image URL parameters.

4 min

read

5

sources

Oct 28, 2026

updated

Scaplet Editorial Team

author

In one line

Sanity's image type does not include an alt text field, so add one in the schema and render it in your `<img>`. Request images through the CDN with `w`, `fit=max` and `auto=format` instead of the original file, and build URLs with `@sanity/image-url` so the editor's crop and hotspot are respected. Name files descriptively with a vanity filename.

30-second check

## Where does your site stand?

Four quick questions, then a straight answer.

1/4Have you checked your own site for this?

Summarize this page with [ChatGPT](https://chatgpt.com/?hints=search&q=Summarize%20https%3A%2F%2Fscaplet.com%2Fseo%2Fsanity%2Fimage-seo%20(%22Sanity%20image%20SEO%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Claude](https://claude.ai/new?q=Summarize%20https%3A%2F%2Fscaplet.com%2Fseo%2Fsanity%2Fimage-seo%20(%22Sanity%20image%20SEO%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Perplexity](https://www.perplexity.ai/search?q=Summarize%20https%3A%2F%2Fscaplet.com%2Fseo%2Fsanity%2Fimage-seo%20(%22Sanity%20image%20SEO%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [![Google](/logos/ai/google-color.svg)AI Mode](https://www.google.com/search?udm=50&q=Summarize%20https%3A%2F%2Fscaplet.com%2Fseo%2Fsanity%2Fimage-seo%20(%22Sanity%20image%20SEO%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.)

On this page

## 5 parts, 4 minutes.

1. [Code first: schema field and a sized, responsive image 01](#code-first-schema-field-and-a-sized-responsive-image)
2. [What Sanity handles and what you must do 02](#what-sanity-handles-and-what-you-must-do)
3. [URL parameters that matter for SEO and speed 03](#url-parameters-that-matter-for-seo-and-speed)
4. [Alt text and file names, per Google 04](#alt-text-and-file-names-per-google)
5. [Check it worked 05](#check-it-worked)

_01_Check it

## Code first: schema field and a sized, responsive image

Sanity's image type documentation says the `fields` property adds optional fields to the image record, such as `caption` and `attribution`. The same mechanism carries [alt text](/glossary/alt-text). The docs' own example reads `image.alt` and notes that "Depending on your schema, you may need to adjust the alt text location", so the field is yours to define.

Responsive image (pattern from Sanity's docs)

```
<img src={urlFor(image).width(800).url()} srcSet={[ \`${urlFor(image).width(400).url()} 400w\`, \`${urlFor(image).width(800).url()} 800w\`, \`${urlFor(image).width(1200).url()} 1200w\`, ].join(', ')} sizes="(max-width: 600px) 400px, (max-width: 1200px) 800px, 1200px" alt={image.alt || ''} />
```

Pass the whole image field, not just the asset, to `urlFor`: Sanity's presenting-images guide says it needs the crop and hotspot data. Google recommends always specifying a fallback `src` for [responsive images](/glossary/responsive-images) because some browsers and crawlers do not understand `srcset`, which the [snippet](/glossary/snippet) does.

Schema field

```
defineField({ name: 'image', type: 'image', options: { hotspot: true }, fields: [ defineField({ name: 'alt', type: 'string', title: 'Alternative text', description: 'Describe what the image shows for someone who cannot see it.', }), ], })
```

_02_Image SEO responsibilities

## What Sanity handles and what you must do

Task

### Alt text

Sanity

No built-in field

You

Add the field, require it where it matters, render it

Task

### Resizing

Sanity

Transforms by URL parameter on the CDN

You

Request only the sizes you display

Task

### Format

Sanity

`auto=format` returns the most optimized format the browser's `Accept` header allows

You

Add the parameter to every URL

Task

### Crop and hotspot

Sanity

Editor sets them in Studio when `hotspot` is enabled

You

Use `@sanity/image-url` so they apply

Task

### File name

Sanity

Default URL has an opaque asset ID

You

Append a vanity file name

Task

### [Image sitemap](/glossary/image-sitemap)

Sanity

No

You

Optional; Next.js sitemap entries accept an `images` array

_03_From Sanity's image transformations reference

## URL parameters that matter for SEO and speed

Parameter

### `w`, `h`

What the docs say

Scales the image to that width or height in pixels

Why it matters

Do not ship the original upload to a 400px slot

Parameter

### `fit=max`

What the docs say

Fits the box but never scales the image up

Why it matters

Without it, small images "get scaled up" to the size you ask for

Parameter

### `auto=format`

What the docs say

Returns the most optimized format supported by the browser, from its `Accept` header

Why it matters

Modern formats without changing your [markup](/glossary/structured-data)

Parameter

### `fm=webp`

What the docs say

Converts to `jpg`, `pjpg`, `png` or `webp`; `avif` is not valid for `fm`

Why it matters

Use in non-browser contexts such as feeds and email

Parameter

### `q`

What the docs say

Quality 0-100; defaults are 75 for JPG and [WebP](/glossary/webp)

Why it matters

Lower only after comparing results

Parameter

### `dpr`

What the docs say

Device pixel ratio from 0 to 5

Why it matters

Sharper images on dense screens

- **Use integers.** The docs warn that non-integer values for `w` and `h` may cause performance issues or timeouts. `&h=200` is correct and `&h=200.0` may be problematic, including for calculated values.
- **Limit the variety.** Sanity says a front end that limits the sizes and crops it requests gets a tremendous boost from the cache.
- **Mind AVIF timing.** Sanity says the first requests for an AVIF may get WebP or JPG while the AVIF encodes, so test twice.
- **SVG does not transform.** Transformations cover JPEG, PNG, WebP, PJPG, TIFF, AVIF and GIF; convert other formats such as SVG first.
- **The bare asset URL is costly.** Sanity warns that requesting un-optimised images directly can lead to overages in your usage.

Descriptive file name, as the docs describe

```
https://cdn.sanity.io/images/<project>/<dataset>/<asset-id>-1600x900.jpg/dalmatian-puppy-playing-fetch.jpg?w=800&fit=max&auto=format
```

_04_Checklist

## Alt text and file names, per Google

Google says alt text, used with computer vision and page content, helps it understand an image and also improves accessibility. Its own ladder: a missing alt is bad, `alt="puppy"` is better, and `alt="Dalmatian puppy playing fetch"` is best. A keyword-stuffed alt is the bad example. Google also says to avoid generic filenames like `image1.jpg`, and that short descriptive ones such as `my-new-black-kitten.jpg` give light clues. That is the case for the vanity file name above.

First_1_
Write alt from what the image shows in context. Sanity's snippet falls back to an empty `alt` when the field is blank, so decide per image whether that is acceptable and do not let it hide a missing description.

Next_1_
Use a required validation on `alt` for content images, so an editor cannot publish without it.

Then_1_
Check that the format you serve is in Google's list: BMP, GIF, JPEG, PNG, WebP, SVG and AVIF.

_05_How it works

## Check it worked

1. 1

### Check the format

Run Sanity's own test, with your real URL: `curl -sS -I -H 'accept: image/avif,image/webp,image/*' 'https://cdn.sanity.io/images/:projectId/:dataset/:filename?auto=format' | grep 'content-type:'`. The docs say expect `image/webp` first and `image/avif` after waiting around 30 seconds.
2. 2

### Inspect the rendered HTML

In DevTools Elements, confirm the `<img>` has a non-empty `alt` where it should, a `src` fallback and `srcset` URLs with `w` values.
3. 3

### Check the Network panel

Filter by Img and confirm the bytes transferred match the displayed size, not the original upload.
4. 4

### Confirm crop behavior

Move the hotspot in Studio, rebuild and check the image still frames the subject at each ratio you render.

Sources · 5

## Every fact, linked and dated.

Official docs first. The date is when we last opened each page.

- sanity.io
- google.com
- nextjs.org

1. 01 [Image type | Sanity Docs](https://www.sanity.io/docs/studio/image-type) sanity.io · checked 2026-11-01
2. 02 [Presenting images | Sanity Docs](https://www.sanity.io/docs/apis-and-sdks/presenting-images) sanity.io · checked 2026-11-01
3. 03 [Image transformations | Sanity Docs](https://www.sanity.io/docs/apis-and-sdks/image-urls) sanity.io · checked 2026-11-01
4. 04 [Google Image SEO best practices | Google Search Central](https://developers.google.com/search/docs/appearance/google-images) developers.google.com · checked 2026-11-01
5. 05 [sitemap.xml file convention | Next.js docs](https://nextjs.org/docs/app/api-reference/file-conventions/metadata/sitemap) nextjs.org · checked 2026-11-01

Questions

## Asked a lot.

2 questions people ask next, answered from the sources on this page.

_01_ Does Sanity have an alt text field by default?

No. The image type lets you add custom fields, so you define an `alt` string on the image and render it in your markup.

_02_ Should I use fm=webp or auto=format?

Use `auto=format` for browsers so the response follows the Accept header. Use `fm` only where you need a fixed format, and note it does not accept avif.

## Keep learning

[All platform guides](/seo)

[Learn Sanity SEO Headless CMS](/seo/sanity) [Related WebP Performance](/glossary/webp) [Read next Webflow image SEO CMS](/seo/webflow/image-seo) [Do Run a free site audit Free, about two minutes](/site-audit)

Nearby in platform guides
[React Router (Remix) redirects](/seo/remix/redirects) [Sanity SEO](/seo/sanity)

More in Sanity SEO
[Sanity image SEO](/seo/sanity/image-seo) [Sanity redirects](/seo/sanity/redirects) [Sanity structured data](/seo/sanity/structured-data) [Sanity XML sitemap](/seo/sanity/xml-sitemap)

Terms on this page
[Alt text](/glossary/alt-text) [Responsive images](/glossary/responsive-images) [Search snippet](/glossary/snippet) [Image sitemap](/glossary/image-sitemap) [Structured data](/glossary/structured-data) [WebP](/glossary/webp)

Free · 2 minutes

## Tools point. Agencies advise. _This one ships._

Run the free audit, then approve the fixes. Every change can be undone.

[Audit my site free](/site-audit)

Free, no card 60 seconds Nobody will call you

- **46** fixes shipped without a ticket Brightpipe
- **0→7** ChatGPT citations in six weeks Paylane
