For SEO purposes, it's necessary to ensure that your website is not serving duplicate content. It is important to ensure you are not hosting the same content at more than a single URL.
Given the nature of Preview Deployments, and the way they are designed to give a realistic representation of a Production Deployment, they serve duplicate content by default. This article outlines how this case is handled by Vercel, to ensure your SEO ranking is not negatively impacted by duplicate content.
Vercel Preview Deployments are not indexed by search engines by default because the X-Robots-Tag
HTTP header is set to noindex
. If you are using a Custom Domain that is assigned to a non-Production Branch, however, the header X-Robots-Tag: noindex
will not be set.
To confirm the value of the X-Robots-Tag
header, you can use the following curl (already available on most desktop devices) command in your terminal to check your Preview Deployment's headers:
curl -I <preview-deployment-url>
Amongst the output, you will find an X-Robots-Tag
header after executing the curl command.
x-robots-tag: noindex
If you are using a Custom Domain for your preview deployments and wish to override the default behavior of omitting X-Robots-Tag: noindex
, you should first look to inject the response header using your framework's built-in methods.
module.exports = { async headers() { const headers = []; if (process.env.NEXT_PUBLIC_VERCEL_ENV === 'preview') { headers.push({ headers: [ { key: 'X-Robots-Tag', value: 'noindex', }, ], source: '/:path*', }); } return headers; }, };
If you are not using a framework or your framework does not support injecting response headers, you may modify the Header
object in your vercel.json
file.
{ "headers": [ { "source": "/", "has": [ { "type": "host", "value": "example.com" } ], "headers" : [ { "key" : "X-Robots-Tag", "value" : "noindex" } ] } ]}
vercel.json
should only be as a last resort and may lead to other problems.If you believe your Preview Deployment is not showing the correct header, please contact Vercel Support using the support form available from the Vercel dashboard.