Deleting pages in Sanity and resolving related reference issues
This is a common issue in Sanity! You're getting this error because the Home and About pages you're trying to delete are referenced by other documents in your content. Sanity prevents you from deleting documents that have strong references pointing to them - this is a security feature that protects your content integrity.
Finding Which Documents Are Referencing Your Pages
The easiest way to find what's referencing your pages is to use Vision (Sanity's GROQ playground):
- Open Vision in your Studio (usually accessible from the top menu or at
/vision) - Run this query to find all documents referencing your page:
*[references("YOUR_DOCUMENT_ID")]Replace YOUR_DOCUMENT_ID with the actual _id of your Home or About page. You can find the document ID by opening the document in Studio and checking the "Inspect" panel.
Alternatively, you can use this more detailed query that shows you which documents have references:
*[]{_id, title, "references": *[references(^._id)]}[length(references) > 0]This will show you all documents and what's referencing them.
Removing the References
Once you know which documents are referencing your pages, you have several options:
- Open those referencing documents in Studio and remove or change the reference fields pointing to the pages you want to delete
- Delete the referencing documents first (if they're not needed)
- Unset the reference - find the links to these documents in the Studio UI and delete them
Based on discussions in the Sanity community, common places where references hide include:
- Navigation menus or site configuration documents
- Other pages that link to Home/About
- Array fields containing page references
- Sometimes orphaned references from integrations (like your Shopify case)
Making References "Weak" (Future Prevention)
If you want to allow deletion even when references exist, you can modify your schema to use weak references:
{
name: 'pageReference',
type: 'reference',
weak: true, // This allows the referenced document to be deleted
to: [{type: 'page'}]
}With weak references, Sanity won't block deletion - though the referencing documents will have broken links.
The Vision query is your best tool here for tracking down exactly what's holding onto those references. Once you clean those up, you'll be able to delete the Home and About pages without issues!
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.