How to disable the document action "duplicate" in Sanity?
Yes, you can disable the duplicate document action! You can customize which document actions are available in Sanity Studio by creating a document actions resolver.
Here's how to disable the duplicate action:
// In your sanity.config.ts or sanity.config.js
import {defineConfig} from 'sanity'
export default defineConfig({
// ... other config
document: {
actions: (prev, context) => {
// Filter out the duplicate action
return prev.filter((action) => action.action !== 'duplicate')
}
}
})If you want to disable it only for specific document types, you can add conditional logic:
document: {
actions: (prev, context) => {
// Disable duplicate for specific document types
if (context.schemaType === 'myDocumentType') {
return prev.filter((action) => action.action !== 'duplicate')
}
return prev
}
}You can also be more selective by checking the action name directly:
import {DuplicateAction} from 'sanity'
document: {
actions: (prev, context) => {
return prev.filter((action) => action !== DuplicateAction)
}
}This approach works for any of the built-in document actions like PublishAction, UnpublishAction, DeleteAction, DuplicateAction, and DiscardAction. You can filter them out individually or combine multiple conditions to create the exact workflow you need for your content team.
Show original thread2 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.