How to add Facebook domain verification file or meta tag in Sanity?
The solution depends on where your Sanity Studio is hosted. There are two main scenarios:
If You're Self-Hosting Your Studio
If you've deployed your Studio to your own domain (using sanity build to create static files and hosting on Vercel, Netlify, or another platform), you have full control over the domain and can use any of Facebook's verification methods:
Option 1: Add HTML file - Place the verification HTML file in your Studio's static folder before building. Files in this folder get copied to the root of your build output.
Option 2: Add meta tag - You can customize the HTML document by creating a custom index.html template in your Studio project, though this requires ejecting from the default build process.
Option 3: DNS TXT record (easiest) - Since you control the domain, just add the TXT record through your DNS provider. This doesn't require any changes to your Studio code.
If You're Using Sanity-Hosted Studio (*.sanity.studio)
If your Studio is hosted on Sanity's infrastructure at a yourproject.sanity.studio subdomain, you don't have direct control to add verification files or meta tags to that domain.
Best solution: Verify a different domain that you control (like your Next.js frontend) and make Facebook API calls from there instead. You can:
- Verify your frontend domain with Facebook
- Create an API route in your frontend (e.g.,
/api/facebook-publish) - Have your Studio custom action POST to your API route
- Your API route forwards the request to Facebook's Graph API
This keeps Facebook credentials secure on your server and gives you a verified domain for the Graph API.
Which Hosting Are You Using?
If you're unsure, check your Studio URL:
yourproject.sanity.studio= Sanity-hosted (limited customization)- Your own domain = Self-hosted (full control)
For self-hosted Studios, the sanity build command creates static files you can deploy anywhere, giving you full control over the hosting environment and the ability to add verification files, meta tags, or DNS records as needed.
Show original thread31 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.