Adding LLMs.txt file to shopify store

Ok was a bit involved but I have it working now.

If you are curious on the whole process as it’s a bit involved can see the blog here for more details: How to Add LLMS.txt to Shopify (and Win at AI Search)

Recently Shopify has O2O with Cloudflare: Shopify · Cloudflare for Platforms docs

So the idea is the following:

  1. Edge Routing with Cloudflare O2O
    We created proxied CNAME records for both the apex domain and www subdomain, routing traffic through Cloudflare’s edge network.
    This gave us access to modify requests before they touched Shopify’s servers.
  2. The Web Worker Solution
    Using Cloudflare Workers, we wrote a micro-service to listen for /llms.txt requests and respond with a plain-text file — instantly, globally, and securely.

Example Partial Code Snippet to get you started if you need:

export default {
  async fetch(request) {
    const { pathname } = new URL(request.url);

    if (pathname === "/llms.txt" || pathname === "/llms.txt/") {
      const body = `WRITE YOUR LLMS.TXT RAW TEXT HERE`;

      return new Response(body, {
        status: 200,
        headers: {
          "Content-Type": "text/plain; charset=utf-8",
          "Cache-Control": "public, max-age=86400",
          "X-Served-By": "llms-worker" // diagnostic to debug
        },
      });
    }

    // proxy everything else to Shopify
    const origin = "https://example.com";
    return fetch(origin + pathname + new URL(request.url).search, request);
  },
};

  1. Validation and Testing
    Once live, we confirmed the file was being served from the edge using curl headers and Cloudflare ray IDs.
    Shopify stayed untouched — yet /llms.txt was now fully functional and validated by AI crawlers.

To see an example Shopify store we set this up for see here: https://jennaraecakes.com/llms.txt