Faceted navigation is the fastest way for a React storefront to generate more URLs than anyone intended. Take five filters with ten values each. If every filter is optional, that is 11 to the power of 5, or 161,051 combinations, before you add sorting and pagination. Each one is a valid URL that returns a page, and crawlers will happily try to fetch all of them.
Google's documentation is blunt about this: there is often no good reason to let crawlers fetch filtered pages, and doing so costs a lot of server resources for little benefit. The fix is a design decision, not a meta tag. Decide which filter states deserve their own URL, give those a clean and linkable route, and keep everything else out of the crawlable link graph.
Three kinds of filter state
In practice every filter combination falls into one of three groups:
- Landing facets. A category plus one filter that people actually search for, such as running shoes from one brand. These get a clean path, a self-referencing canonical, a place in the sitemap and real
<a href>links. - User-only state. Color, size, price range, sorting, "in stock only". Useful on the page, worthless as a search result. These should not appear in crawlable links.
- Pagination. Not a filter, but it multiplies everything else, so it gets its own rules below.
Encoding that decision in one module keeps it consistent across the filter UI, the sitemap and the canonical tag:
// lib/facets.ts export type Filters = Record<string, string[]>; const LANDING_FACETS = new Set(["brand", "type"]); export function landingPath(category: string, filters: Filters): string | null { const active = Object.entries(filters).filter(([, values]) => values.length > 0); if (active.length === 0) return `/${category}`; if (active.length > 1) return null; const [key, values] = active[0]; if (!LANDING_FACETS.has(key) || values.length !== 1) return null; return `/${category}/${key}/${encodeURIComponent(values[0])}`; } export function filterQuery(filters: Filters): string { const params = new URLSearchParams(); for (const key of Object.keys(filters).sort()) { for (const value of [...filters[key]].sort()) params.append(key, value); } return params.toString(); } landingPath answers "does this state deserve its own page?" and filterQuery produces a stable parameter order for everything else. A stable order matters because ?size=42&color=red and ?color=red&size=42 are two different URLs to a crawler.
Rendering the filter UI
If landingPath returns a path, render the option as a next/link, which outputs a real anchor. If it returns null, render a checkbox or button that updates the query string with router.replace. The page still works with shareable URLs, but the HTML does not contain thousands of links into parameter combinations.
Shared links and old bookmarks will still lead crawlers to some of those URLs, so add a robots.txt rule for the user-only parameters:
// app/robots.ts import type { MetadataRoute } from "next"; export default function robots(): MetadataRoute.Robots { return { rules: { userAgent: "*", disallow: ["/*?*color=", "/*?*size=", "/*?*price=", "/*?*sort="], }, sitemap: "https://shop.example/sitemap.xml", }; } One trap: a URL blocked in robots.txt is never fetched, so a noindex or canonical on that page is never seen. Pick one mechanism per URL pattern. Google's faceted navigation guide also mentions a third option: if filters live in the URL fragment (#color=red), they have no effect on crawling at all.
When a filter combination returns no products, respond with a 404 rather than an empty grid with a 200. Google's guidance asks for exactly that, and it stops empty combinations from looking like real pages.
Infinite scroll that crawlers can follow
Crawlers do not scroll and do not click "load more". Google's guidance for incremental loading comes down to three rules: every chunk has its own URL such as ?page=3, each page links to the next with a normal <a href>, and each page uses itself as the canonical rather than page 1. rel="next" and rel="prev" are no longer used by Google.
You can keep infinite scroll for users and still meet those rules by treating the "next page" link as the source of truth and enhancing it:
"use client"; import Link from "next/link"; import { useEffect, useRef, useState } from "react"; type Product = { id: string; name: string; href: string }; type Chunk = { items: Product[]; nextPage: number | null }; export function ProductList({ category, first }: { category: string; first: Chunk }) { const [items, setItems] = useState(first.items); const [next, setNext] = useState(first.nextPage); const sentinel = useRef<HTMLAnchorElement>(null); useEffect(() => { if (!sentinel.current || next === null) return; const observer = new IntersectionObserver(async ([entry]) => { if (!entry.isIntersecting) return; observer.disconnect(); const chunk: Chunk = await fetch(`/api/${category}?page=${next}`).then((r) => r.json()); setItems((prev) => [...prev, ...chunk.items]); setNext(chunk.nextPage); window.history.replaceState(null, "", `?page=${next}`); }); observer.observe(sentinel.current); return () => observer.disconnect(); }, [category, next]); return ( <> <ul> {items.map((p) => ( <li key={p.id}><Link href={p.href}>{p.name}</Link></li> ))} </ul> {next !== null && ( <Link ref={sentinel} href={`/${category}?page=${next}`}>Next page</Link> )} </> ); } Without JavaScript, the server-rendered page shows one chunk and a working link to the next. With JavaScript, the same link becomes the scroll trigger. The App Router integrates window.history.replaceState, so the address bar follows the user without a navigation. On the server, call notFound() for a page number beyond the last page, before any Suspense boundary, so it returns a real 404.
Checking what a crawler finds
The quickest test is to count the URLs your templates expose. Crawl a staging build within a defined scope and group the results by pattern: if parameter URLs outnumber product URLs, the filter UI is still leaking links. Crawl Foundry Site Audit, the SEO tool I build as a side project, lets you filter every crawled URL by status, metadata and indexability in its Page Explorer, which makes that kind of leak easy to spot. See the Site Audit feature page.
For the background, the glossary covers crawl budget optimization, URL structure and the canonical tag.
