Thinkmill / Thinkmill/keystatic
Feature Request: Automatic filename sanitization on upload
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.4k
- Forks
- 159
- Avg merge
- 21h 41m
- Merged PRs (30d)
- 2
Description
Feature Request: Automatic filename sanitization on upload
Summary
When uploading images or files through Keystatic, filenames should be automatically sanitized to remove spaces, special characters, and other problematic characters that can cause issues with Git, URLs, and various file systems.
Problem
Currently, Keystatic accepts filenames as-is from the user's file system. This leads to several issues:
-
Broken builds/deploys: Filenames with spaces or special characters (e.g.,
Screenshot 2025-12-15 (1).jpg) can cause GraphQL errors when committing to GitHub:[GraphQL] A path was requested for deletion which does not exist as of commit oid `...` -
URL encoding issues: Spaces become
%20in URLs, parentheses and other characters can break paths -
Cross-platform problems: Different file systems handle special characters differently
-
Poor developer experience: Users have to manually rename files before every upload
Expected behavior
When a file is uploaded, Keystatic should automatically sanitize the filename:
| Original filename | Sanitized filename |
|---|---|
| Screenshot 2025-12-15 (1).jpg | screenshot-2025-12-15-1.jpg |
| My Document.pdf | my-document.pdf |
| Über File — Recipe.png | uber-file-recipe.png |
Suggested implementation
- Convert to lowercase
- Replace spaces with hyphens
- Remove or transliterate special characters (
(),[],&, etc.) - Remove or transliterate accented characters
- Collapse multiple hyphens into one
- Trim hyphens from start/end
Optionally, this could be:
- A configurable option in
keystatic.config.ts - Enabled by default with an option to disable
Environment
- Keystatic Cloud
- Astro + Netlify
- GitHub storage mode
Additional context
This is standard behavior in most CMS platforms (WordPress, Drupal, Sanity, etc.) and would significantly improve the user experience, especially for non-technical content editors who don't think about filename conventions.
The Keystatic upload tool documentation already notes that filenames should "only contain alphanumeric characters, dashes and underscores" — it would be great if Keystatic enforced/fixed this automatically.
Happy to help test or contribute if needed!
# Feature Request: Automatic filename sanitization on uploadSummary
When uploading images or files through Keystatic, filenames should be automatically sanitized to remove spaces, special characters, and other problematic characters that can cause issues with Git, URLs, and various file systems.
Problem
Currently, Keystatic accepts filenames as-is from the user's file system. This leads to several issues:
-
Broken builds/deploys: Filenames with spaces or special characters (e.g.,
Screenshot 2025-12-15 (1).jpg) can cause GraphQL errors when committing to GitHub:[GraphQL] A path was requested for deletion which does not exist as of commit oid `...` -
URL encoding issues: Spaces become
%20in URLs, parentheses and other characters can break paths -
Cross-platform problems: Different file systems handle special characters differently
-
Poor developer experience: Users have to manually rename files before every upload
Expected behavior
When a file is uploaded, Keystatic should automatically sanitize the filename:
| Original filename | Sanitized filename |
|---|---|
Screenshot 2025-12-15 (1).jpg |
screenshot-2025-12-15-1.jpg |
My Document.pdf |
my-document.pdf |
Über File — Recipe.png |
uber-file-recipe.png |
Suggested implementation
- Convert to lowercase
- Replace spaces with hyphens
- Remove or transliterate special characters (
(),[],&, etc.) - Remove or transliterate accented characters
- Collapse multiple hyphens into one
- Trim hyphens from start/end
Optionally, this could be:
- A configurable option in
keystatic.config.ts - Enabled by default with an option to disable
Environment
- Keystatic Cloud
- Astro + Netlify
- GitHub storage mode
Additional context
This is standard behavior in most CMS platforms (WordPress, Drupal, Sanity, etc.) and would significantly improve the user experience, especially for non-technical content editors who don't think about filename conventions.
The [Keystatic upload tool documentation](https://github.com/JedWatson/keystatic-upload-tool) already notes that filenames should "only contain alphanumeric characters, dashes and underscores" — it would be great if Keystatic enforced/fixed this automatically.
Happy to help test or contribute if needed!
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the upload-tool documentation and the upload handling path, then review keystatic.config.ts to determine whether sanitization should be configurable. Compare the documented filename constraints with the examples in this issue and define behavior for extensions, transliteration, collisions, and disabling the feature. Done means uploads consistently produce the agreed safe filenames in GitHub storage mode.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend, content
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100