IndexNow for Shopify
How to handle IndexNow key-file hosting on Shopify storefronts without hitting off-host redirect or subdirectory scope errors.
The Shopify root-file constraint
Standard Shopify Online Store themes do not let you upload arbitrary static .txt files to your custom domain root (https://store.example.com/<key>.txt). Creating a Shopify URL Redirect pointing to a file on cdn.shopify.com fails IndexNow verification because search engines reject off-host redirects.
Similarly, serving a key via a Shopify App Proxy under /apps/indexnow/key.txt only authorizes URLs starting with /apps/indexnow/ — it cannot authorize /products/ or /collections/ pages due to IndexNow’s subdirectory scope rule.
Three reliable architectures on Shopify
- Cloudflare Worker / O2O proxy in front of your custom domain
- Intercept exact requests to /<key>.txt at the edge and return HTTP 200 text/plain with the key body while proxying all other storefront traffic to Shopify.
- Shopify Hydrogen / Oxygen headless storefront
- Place <key>.txt in public/<key>.txt (or return it from a root route loader) so it serves natively at https://store.example.com/<key>.txt with zero redirects.
- Webhook-driven product & collection pushes
- Subscribe to Shopify products/create, products/update, and products/delete webhooks in a lightweight worker to submit only changed product URLs for flash sales, restocks, and price updates.
Edge route example for serving the key file
export default {
async fetch(request, env) {
const url = new URL(request.url);
if (url.pathname === `/${env.INDEXNOW_KEY}.txt`) {
return new Response(env.INDEXNOW_KEY, {
status: 200,
headers: {
"Content-Type": "text/plain; charset=utf-8",
"Cache-Control": "public, max-age=3600",
},
});
}
return fetch(request);
},
};