Free auditStart free
GuideSanity · Images

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.

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 withChatGPTClaudePerplexityGoogleAI Mode
01Check 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. 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 because some browsers and crawlers do not understand srcset, which the 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.',
    }),
  ],
})
02Image 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

Sanity
No
You
Optional; Next.js sitemap entries accept an images array
04Checklist

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.
First1
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.
Next1
Use a required validation on alt for content images, so an editor cannot publish without it.
Then1
Check that the format you serve is in Google's list: BMP, GIF, JPEG, PNG, WebP, SVG and AVIF.
05How 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. 01Image type | Sanity Docssanity.io · checked 2026-11-01
  2. 02Presenting images | Sanity Docssanity.io · checked 2026-11-01
  3. 03Image transformations | Sanity Docssanity.io · checked 2026-11-01
  4. 04Google Image SEO best practices | Google Search Centraldevelopers.google.com · checked 2026-11-01
  5. 05sitemap.xml file convention | Next.js docsnextjs.org · checked 2026-11-01
Questions

Asked a lot.

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

01Does 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.

02Should 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.

Free · 2 minutes

Tools point. Agencies advise. This one ships.

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

Free, no card60 secondsNobody will call you
  • 46 fixes shipped without a ticket Brightpipe
  • 0→7 ChatGPT citations in six weeks Paylane