Sanity image filename changes not reflecting on production site
I understand your frustration! The filename changes you're making in Sanity Studio are indeed cosmetic for the Studio interface only - they don't automatically change the actual CDN URLs that your production site uses.
Here's what's happening: When you upload an image to Sanity, it's stored with a hash-based filename (like bc4ade6a97553e67ac0e2c336f27004c8c7cd07c-1000x1000.png). This hash is based on the file's content and ensures cache efficiency - it never changes unless the actual image file changes.
The Solution: Vanity Filenames
Sanity supports what's called "vanity filenames" for SEO purposes. You can append your SEO-friendly filename to the end of the hash-based URL, and it will still work perfectly!
The format is:
https://cdn.sanity.io/images/<projectId>/<dataset>/<hashedFileName>/<your-seo-filename.png>?<params>
For example:
https://cdn.sanity.io/images/yourproject/production/bc4ade6a97553e67ac0e2c336f27004c8c7cd07c-1000x1000.png/product-name-seo-friendly.png?w=800
Implementation Steps
Query the original filename from your image asset documents (it's stored in the
originalFilenamefield or you can use a custom field you've designated for SEO-friendly names)Append it to your image URLs when building them in your frontend code. If you're using
@sanity/image-url, you'll need to manually append the vanity filename to the generated URL.Update your image URL builder to include this filename. For example:
const imageUrl = urlFor(image).url() + '/' + image.asset.originalFilename
The beauty of this approach is that the hash portion remains unchanged (so caching works perfectly), but search engines see the SEO-friendly filename in the URL path, which is exactly what Google's image SEO guidelines recommend.
Important notes:
- You don't need to re-upload images or clear caches
- Just update how your frontend code constructs the image URLs
- All image transformation parameters (like
?w=800&auto=format) continue to work normally after the vanity filename - The
dlparameter you found is different - it forces a download with that filename, but doesn't change the URL for SEO purposes
So to answer your question directly: yes, the Studio filename changes are cosmetic, but you can achieve your SEO goals by implementing vanity filenames in your frontend code!
Show original thread10 replies
Sanity – Build the way you think, not the way your CMS thinks
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.