Ecommerce Academy · Chapter 11
JavaScript and headless storefronts
A headless or JavaScript-heavy storefront can be read by crawlers as long as the server sends each page's essentials in the HTML: product name, description, price, stock, links to other pages, the right status code and the canonical tag. The framework isn't the risk. The risk is a storefront that sends an empty shell and builds everything in the browser, because many AI crawlers appear not to run JavaScript. Why, and how to check a page's text, is covered in content that only appears with JavaScript. This lesson covers what headless stores get wrong beyond the text.
Where headless stores slip
Prices and stock fetched after load. Many headless builds draw the page, then call the commerce API for live price and inventory. A crawler that doesn't run scripts gets a product with no price. Render price and availability on the server, and refresh them in the browser if you need to.
Links that aren't links. Google says it finds links only in <a> elements with an href attribute, and its ecommerce guidance says not to use JavaScript events on other elements for navigation. A category grid built from clickable divs hides your products from crawlers.
Every URL answers 200. A single-page app often returns 200 for a product that no longer exists, then shows "not found" in the browser. Google calls these soft 404s. Its JavaScript SEO basics suggest redirecting to a URL that returns a real 404, or adding noindex with JavaScript. Simpler still: have the server return 404 for unknown products.
Canonicals set by script. Google says the best place for the canonical tag is the HTML, and that JavaScript should never change it to a different URL from the one in the original HTML. Send the canonical, title and meta description in the server response.
Fragment routes. Google says addresses like /#/product/trail-2 can't be resolved reliably and recommends the History API, which gives each product a real path.
Choosing how to render
Server-side rendering and static generation both send complete HTML on the first request, and most headless frameworks support one or both. Google calls dynamic rendering, serving a separate prerendered version only to bots, a workaround and not a long-term solution, and points to server-side rendering, static rendering or hydration instead.
This week
Fetch three URLs with curl: a product page, a category page and a product address that doesn't exist. Check that the first two contain the price, stock status, canonical and product links as plain HTML, and that the third returns a 404 status rather than a 200.
Sources
- Google, "Understand the JavaScript SEO basics", Mar 4, 2026 (opens in a new tab)
- Google, "Help Google understand your ecommerce website structure", Dec 10, 2025 (opens in a new tab)
- Google, "Dynamic rendering as a workaround", Dec 10, 2025 (opens in a new tab)
- Vercel, "The rise of the AI crawler", Dec 17, 2024 (opens in a new tab)