Sub topic 4
Parameter, faceted and paginated URLs
This chapter assumes you can read a crawl export and normalize URLs as in the previous chapter. You should also know what a query string is, meaning the part of a URL after ?. Basic pandas grouping is enough for the code.
Why parameters create duplicates
A parameter is a key and value pair in the query string, such as ?color=red. Parameters make one page many URLs. A crawler follows each link it finds, so a single category page can turn into thousands of crawled URLs. Many of these show almost the same content.
Normalization removes tracking parameters, but other parameters change what the page shows. You have to decide, for each parameter, whether it changes the content.
Three common families
| Family | Example | What it does | Typical duplicate risk |
|---|---|---|---|
| Tracking and session | `?utm_source=news`, `?sessionid=9f2` | Changes nothing on the page | Exact duplicate of the clean URL |
| Sorting and view | `?sort=price`, `?view=list` | Reorders or reformats the same items | Near duplicate, same items in a different order |
| Faceted filters | `?color=red&size=9` | Selects a subset of items | Near duplicate or thin page, depending on the subset |
Pagination (?page=2) is a fourth case. Each page lists different items, so pages are not duplicates of each other. Problems appear when the paginated pages share the same title and heading, or when a ?page=1 URL repeats the base URL.
Classify parameters in your crawl
Start by counting which kinds of parameter URLs the crawl found. This script labels each URL by its parameters. Adjust the sets to match the site you are auditing.
from collections import Counter
from urllib.parse import urlsplit, parse_qsl
TRACKING = {"utm_source", "utm_medium", "utm_campaign", "gclid", "fbclid"}
FACETS = {"color", "size", "brand"}
SORT = {"sort", "order"}
def classify(url):
keys = {k for k, _ in parse_qsl(urlsplit(url).query)}
if not keys:
return "none"
if keys <= TRACKING:
return "tracking"
if keys & FACETS:
return "facet"
if keys & SORT:
return "sort"
if "page" in keys:
return "pagination"
return "other"
urls = [
"https://example.com/shoes",
"https://example.com/shoes?color=red",
"https://example.com/shoes?utm_source=news",
"https://example.com/shoes?sort=price&page=2",
"https://example.com/shoes?page=3",
]
print(Counter(classify(u) for u in urls))Check the other bucket by hand. It usually holds parameters you did not know existed, such as internal search terms or calendar dates.
Decide how each family should behave
The right handling depends on whether the URL deserves to rank on its own.
flowchart TDFor tracking parameters, the clean URL is the target. For sorting, the unsorted category is usually the target. For facets, keep only combinations that match something people search for, such as "red running shoes". Treat the rest as duplicates.
Check pagination separately
For paginated series, check these in the crawl:
- Each page has a self-referencing canonical, not a canonical pointing to page 1. Pointing every page to page 1 hides the products on deeper pages.
- Titles or headings include the page number, or at least differ enough to be told apart.
?page=1redirects or canonicalizes to the base URL.- Deep pages are still linked, so the items on them can be found.
Watch the crawl budget signal
A large share of parameter URLs, or inlinks pointing at them, shows that the site generates these links itself. Fixing the link source is often better than tagging each URL. Note the source template for the next chapters, where duplicates are grouped and a preferred URL is chosen.
Exercise
A crawl shows /shoes?sort=price, /shoes?sort=rating and /shoes with the same 40 products in different order. Which family is this, and what is a sensible target for the sorted URLs?
Show answer
It is the sorting family, and the sorted URLs are near duplicates of the base category. A sensible target is /shoes, using a canonical tag (or a redirect if the sorted URLs are not needed), because the sorted pages add no new content or search demand.