How to customize Sanity CDN file URLs to be human-readable instead of hash?
Unfortunately, you cannot change the hash-based path segment in Sanity's CDN file URLs. The hash (like 0a58f9ef059ce5d5995b1ede2d31149dc79d287c.pdf) is content-addressable and fundamental to how Sanity's CDN works - it ensures cache integrity and prevents collisions.
However, there are two approaches you can use to improve the user experience:
1. Vanity Filenames (For Images Only)
For images, Sanity supports vanity filenames where you can append a human-readable name after the hash:
https://cdn.sanity.io/images/PROJECT/DATASET/HASH-WIDTHxHEIGHT.FORMAT/event-timetable.png
Unfortunately, this feature is only available for images, not PDF or other file assets. Files served through cdn.sanity.io/files/ don't support vanity filenames in the path.
2. The ?dl= Parameter (Your Current Approach)
The ?dl= parameter you're already using is the correct and only way to control the download filename for file assets. While it doesn't change the URL path itself, it does set the Content-Disposition header, which determines what filename the browser uses when downloading:
https://cdn.sanity.io/files/PROJECT/DATASET/HASH.pdf?dl=event-timetable.pdf
This is the standard approach for file downloads and works well for SEO and user experience when files are actually downloaded.
Alternative: Proxy Through Your Own Domain
If human-readable URLs are critical for your use case (for SEO or branding), you could:
- Create a custom endpoint in your application (e.g.,
/downloads/event-timetable.pdf) - Map friendly names to the actual Sanity CDN URLs in your code
- Redirect or proxy requests to the actual Sanity CDN URL
This gives you full control over the URL structure users see, while still leveraging Sanity's CDN for the actual file delivery.
The hash-based system is intentional - it provides content-addressable storage, automatic deduplication, and reliable caching. While it's not human-readable, the ?dl= parameter ensures users still get meaningful filenames when downloading.
Show original thread1 reply
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.