An online shop with a few hundred products can easily have millions of addresses. Every filter, sort order, page number and combination of them creates a new URL, and most of them show the same products in a slightly different arrangement. Crawlers that wander into that maze spend their time on near-duplicates instead of on the product and category pages that should be found.
Robots.txt is the main tool for keeping crawlers out of that maze. This post covers which parts of a shop to block, which to leave open, and how to test the result before it costs you traffic.
Where the endless addresses come from
Google’s guidance on URL structure names the usual culprits. Additive filters, where shoppers can combine colour, size, price and brand, multiply the number of addresses rapidly. Sorting and referral parameters add more versions of the same page. Session IDs in addresses create a new URL for every visitor. Google’s advice includes trimming unnecessary parameters and avoiding session IDs in URLs, and it notes that robots.txt can be used to block problematic addresses.
| Source | Example | Usually |
|---|---|---|
| Sort order | /shoes?sort=price | Block |
| Combined filters | /shoes?colour=red&size=9&brand=x | Block most combinations |
| Internal search | /search?q=red+shoes | Block |
| Session or tracking IDs | /shoes?sessionid=123 | Block, and remove from links |
| Cart, checkout, account | /cart/, /checkout/ | Block |
| Category pages | /shoes/ | Keep crawlable |
| Product pages | /shoes/oak-brogue/ | Keep crawlable |
A starting file for a shop
User-agent: *
Disallow: /cart/
Disallow: /checkout/
Disallow: /account/
Disallow: /search
Disallow: /*?sort=
Disallow: /*&sort=
Disallow: /*sessionid=
Sitemap: https://www.example.com/sitemap.xml
The two sort patterns catch the parameter whether it comes first in the query string or later; how the asterisk patterns match is explained in robots.txt wildcards. The session pattern catches the parameter anywhere in the address. Product and category pages are not matched by any line, so they stay open. Adapt the paths to your platform; the names differ from one shop system to another.
The hard part: filters
Filters are where shops gain or lose the most. Some filtered pages are valuable: a page of “red running shoes” may match exactly what people search for. Most combinations are not: “red running shoes, size 9, under 50, sorted by newest” is a page nobody searches for.
A practical approach:
- Decide which filters deserve their own pages. Usually one dimension at a time, such as colour or brand within a category, and only where people search for that combination.
- Give those pages clean, permanent addresses, such as /running-shoes/red/, with their own headings and descriptions, rather than relying on parameters.
- Block the parameter versions that create the endless combinations.
The result is a shop with a manageable set of crawlable pages, each worth indexing, and a robots.txt that keeps crawlers out of everything else. Readable addresses for those chosen filter pages are easier to build with the URL slug generator.
Pagination
Category pages split across several pages, such as /shoes/?page=2, are different from filters. The later pages are how crawlers reach products deep in a large category, so blocking them can hide those products. In most shops, pagination should stay crawlable, with each page linking to the next.
What not to block
- Product pages, obviously, but check that no pattern catches them by accident, for example a rule for a parameter that also appears in product addresses.
- Category pages, including their paginated pages.
- Images, scripts and styles that pages need to render.
- Pages you want removed from results. Blocking them stops crawlers seeing a noindex, so the pages can stay listed.
Test against real addresses
Every rule should be tested against real addresses from your own shop, because platforms put parameters in different places and in different orders. Collect a sample:
- a few product pages, including ones with unusual characters in their names;
- a few category pages, with and without page numbers;
- the filter pages you decided to keep;
- a sorted category, a filtered combination, a search result and the cart.
Paste the file and the list into the robots.txt tester. It shows, for every address, whether it is allowed or blocked and which rule decided it. Every product and category must come back allowed; every sort, combination, search and cart address blocked. Anything surprising is a rule to fix before it goes live. The robots.txt generator writes a clean starting file if you are building from scratch.
Robots.txt is one tool among several
Blocking crawling is the most direct way to stop crawlers wasting time on filter combinations, but it works best with the rest of the shop set up to match:
- Links to filtered pages that should not be crawled can be kept out of the plain HTML where the platform allows, so crawlers discover fewer of them in the first place.
- Canonical tags on parameter versions can point to the main category page, which helps consolidate signals for any variants that are crawled.
- The sitemap should list only products, categories and the filter pages you chose to keep.
- Internal links should point to clean addresses, not to versions carrying sort or session parameters.
Watch the effect
After changing robots.txt, watch Search Console’s reports over the following weeks. The number of pages crawled should shift towards products and categories, and the pages you care about should stay indexed. If important pages start dropping out, check whether a new rule is blocking them, using the tester on the exact addresses affected.
Platforms that write the file for you
Many shop platforms generate a robots.txt automatically, often with sensible defaults for carts, checkouts and account pages. Before adding your own rules, read what the platform already sends at /robots.txt. Some platforms let you add lines to the generated file; others let you replace it entirely. Adding a duplicate group for the same crawler can change which rules apply, so extend the existing file rather than writing a second set beside it.
When a shop changes platform, the paths for carts, searches and filters usually change too. A robots.txt carried over unchanged from the old platform can block nothing useful on the new one, or block something important. Rewrite it for the new paths and test it again.
Seasonal and out-of-stock products
Products that go out of stock or return every season are better left crawlable. Blocking them in robots.txt means search engines cannot see when they come back, and the pages lose their place in results. Keep the page live with a clear availability message, or redirect permanently to the closest replacement if the product is gone for good. Robots.txt is for addresses that should never be crawled, not for products that are temporarily unavailable.
Product variants
Variants, the same product in different colours or sizes, are sometimes given their own addresses through parameters. Whether to keep them crawlable depends on whether people search for the variant. “Red oak table” may deserve its own page; “oak table, 180 cm, in stock” probably does not. Block the parameter versions that only change a minor option, and make sure the main product page is reachable and listed in the sitemap.
Internal search pages that do earn traffic
Some shops build landing pages from internal search, such as a page for a popular search term with a proper heading and description. If those pages are valuable, give them clean addresses outside the blocked search path, link to them from category pages and list them in the sitemap. Leave the raw search results blocked. That way the few search-based pages that deserve to rank can, while the endless variations stay out of crawlers’ way.
Checking the effect on crawling
After a change, the crawl statistics in Search Console show how many requests Google made to the site and which kinds of response it got. A good robots.txt for a shop typically shifts crawling towards product and category pages over the following weeks. If crawling of important pages falls instead, or the number of indexed products drops, a rule is probably catching more than intended.
A test list worth keeping
Save the list of test addresses you used, with the result each one should give. Every time the robots.txt file changes, or the shop platform is updated, run the same list again. Ten minutes of testing catches the kind of mistake that otherwise shows up weeks later as products quietly disappearing from search results.
Common mistakes in shop files
- Blocking all parameters with a single broad rule, which can catch pagination or product variants that need to be crawled.
- Forgetting parameter order: a rule for ?sort= misses the same parameter when it appears after another one.
- Blocking filter pages that bring search traffic, such as a brand page people search for.
- Leaving session IDs in internal links, which creates new addresses faster than any rule can block them.
- Using robots.txt to remove pages from results, which it cannot do.
Sources, read November 14, 2026:
- Google Search Central, URL structure best practices: additive filters multiplying URLs, trimming unnecessary parameters, avoiding session IDs in URLs, and robots.txt to block problematic URLs.