Is there an easy way of clearing unwanted published items?
"result":[2 items
0:{6 items
"_createdAt":"2020-10-30T07:44:59Z"
"_id":"932ebb41-cf8d-463d-9ad9-6e4c88588b54"
"_rev":"XNtMa4Y66vmVFnyOJAoV3C"
"_type":"siteSettings"
"_updatedAt":"2020-10-30T08:08:55Z"
"owner":{4 items
"facebook":"@facebook"
"instagram":"@instagram"
"name":"Amy Robers"
"twitter":"@twitter"
}
}
1:{8 items
"_createdAt":"2020-10-30T11:51:03Z"
"_id":"siteSettings"
"_rev":"XNtMa4Y66vmVFnyOJEK8AQ"
"_type":"siteSettings"
"_updatedAt":"2020-10-30T15:53:17Z"
"name":"Amy"
"person":{3 items
"facebook":"<https://yourfacebookurl/>"
"instagram":"<https://yourinstagramurl/>"
"twitter":"<https://yourtwitterurl/>"
}
"website":"<http://yogawithamy.com|yogawithamy.com>"
}
]Looking at your data, you have two documents of type siteSettings with different _id values:
"932ebb41-cf8d-463d-9ad9-6e4c88588b54"(created first)"siteSettings"(created later)
This is a common issue when setting up singleton documents - you've accidentally created multiple instances of what should be a single-instance document type.
To fix this, you need to delete the duplicate document. Here's how:
Go to your Sanity Studio and navigate to Vision (the query tool)
Run this query to verify which document you want to keep:
*[_type == "siteSettings"]Delete the unwanted document (likely the first one with the UUID). You can do this by:
- Finding it in your Studio content list and deleting it manually, OR
- Using the Vision tool with this mutation:
// Delete by ID sanity.delete('932ebb41-cf8d-463d-9ad9-6e4c88588b54')
Based on your data, you probably want to keep the second one (_id: "siteSettings") since it has your actual content (name: "Amy", website, etc.) and delete the first one.
To prevent this from happening again, configure your siteSettings as a proper singleton in your sanity.config.ts:
export default defineConfig({
// ... other config
schema: {
types: schemaTypes,
templates: (templates) =>
templates.filter(({ schemaType }) => schemaType !== 'siteSettings')
},
document: {
actions: (input, context) =>
context.schemaType === 'siteSettings'
? input.filter(({ action }) => !['duplicate', 'delete', 'unpublish'].includes(action))
: input
}
})This prevents creating additional instances through the "New document" menu and removes dangerous actions like duplicate/delete from the singleton document.
Show original thread5 replies
Was this answer helpful?
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.