How to Add Internal Links to Top Level Singletons
Based on your CTA object schema, you can easily add references to singleton documents by including them in the to array of your post field. Here's how to modify your existing schema:
{
title: "Internal link",
description: "Use this to link between pages on the website",
name: "post",
type: "reference",
to: [
{ type: "post" },
{ type: "project" },
{ type: "settings" }, // Add your singleton types here
{ type: "homePage" },
{ type: "aboutPage" },
// ... any other singleton document types
],
fieldset: "link",
}The key is that singleton documents are still regular document types in your schema—they just have special configuration to ensure only one instance exists. The reference field works the same way with singletons as it does with regular documents.
Important consideration: Since singletons typically only have one instance, when editors select them in the reference field, they'll see just that single document to choose from. This is actually perfect for your use case—for example, if you have a singleton "Home" page, editors can reference it directly without confusion about which home page to link to.
If you want to make the reference picker clearer for editors, you can add a filter or customize the reference options:
{
title: "Internal link",
name: "post",
type: "reference",
to: [
{ type: "post" },
{ type: "project" },
{ type: "settings" },
],
options: {
filter: '_type in $types',
filterParams: {
types: ['post', 'project', 'settings']
}
},
fieldset: "link",
}Your existing validation logic will continue to work perfectly—it ensures editors can only choose either an internal reference (including singletons) OR an external URL, but not both.
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.