Sub topic 4
Parameter, faceted and paginated URLs
This chapter assumes you can read a crawl export, understand HTTP status codes and canonical tags, and group rows with pandas. It builds on URL normalization from the previous chapter. Normalization removes tracking parameters. This chapter covers the parameters that remain and what they do to a site's duplicate and thin page counts.
Why parameters create so many URLs
A query parameter is a key=value pair after the ? in a URL. A crawler treats every distinct URL as a separate page, whether or not the content differs. A category page with 5 colors, 4 sizes and 3 sort orders can produce hundreds of crawlable URLs. Most of them show the same products in a different order, or a subset of them.
Parameters fall into different roles, and each role needs a different diagnosis.
| Role | Example | Changes the content? | Typical diagnosis |
|---|---|---|---|
| Tracking | `utm_source=news` | No | Exact duplicate of the base URL |
| Session | `sid=8f3a1c` | No | Exact duplicate, often with unbounded URL count |
| Sorting | `sort=price` | Order only | Near duplicate of the base URL |
| View | `view=grid` or `limit=100` | Layout or count | Near duplicate or overlapping subset |
| Facet (filter) | `color=red` | Yes, narrows the list | Subset page, possibly thin, possibly valuable |
| Pagination | `page=2` | Yes, different items | Distinct page that repeats titles and boilerplate |
| Internal search | `q=boots` | Yes | Usually low value, often thin |
The "Changes the content?" column is the part you must verify with data. Parameter names are only hints. A parameter called ref might be tracking on one site and a content selector on another.
Inventory the parameters first
Before you fix anything, list which parameter names appear and how often. This script counts parameter names across a list of URLs. In a real audit, read the list from your crawl export instead.
from collections import Counter
from urllib.parse import urlsplit, parse_qsl
urls = [
"https://example.com/shoes?color=red",
"https://example.com/shoes?color=red&sort=price",
"https://example.com/shoes?page=2",
"https://example.com/shoes?utm_source=news&page=3",
"https://example.com/shoes",
]
counts = Counter()
for url in urls:
for key, _ in parse_qsl(urlsplit(url).query, keep_blank_values=True):
counts[key.lower()] += 1
for key, n in counts.most_common():
print(key, n)Pass keep_blank_values=True. Without it, ?color= is silently dropped, and a blank-value URL is still a separate URL that the crawler recorded.
Sort the result by count. A site usually has a handful of names that account for most of the URLs. Start your analysis with those.
Classify URLs by parameter role
Once you know the names, label each URL. The rule table below is a starting point. Edit it to match the site you are auditing.
from urllib.parse import urlsplit, parse_qsl
RULES = {
"tracking": {"utm_source", "utm_medium", "utm_campaign", "gclid", "fbclid"},
"session": {"sid", "sessionid", "phpsessid"},
"sort": {"sort", "order"},
"pagination": {"page", "p"},
"facet": {"color", "size", "brand", "price"},
}
def classify(url):
keys = {k.lower() for k, _ in parse_qsl(urlsplit(url).query, keep_blank_values=True)}
kinds = {kind for kind, names in RULES.items() if keys & names}
return sorted(kinds) or ["none"]
for u in [
"https://example.com/shoes?color=red",
"https://example.com/shoes?color=red&sort=price",
"https://example.com/shoes?page=2",
"https://example.com/shoes?utm_source=news",
"https://example.com/shoes",
]:
print(u, classify(u))The output shows ['facet'], ['facet', 'sort'], ['pagination'], ['tracking'] and ['none'], in that order. A URL can carry several roles at once. Combinations such as facet plus sort are where the URL count multiplies.
Test whether a parameter changes the content
A parameter name tells you what the developers intended. The page body tells you what actually happens. For each parameter URL, compare its body with the body of the same path without a query string.
import hashlib
import pandas as pd
from urllib.parse import urlsplit, urlunsplit
rows = [
("https://example.com/shoes", "Red shoes Blue shoes Black shoes"),
("https://example.com/shoes?sid=123", "Red shoes Blue shoes Black shoes"),
("https://example.com/shoes?sort=price", "Black shoes Red shoes Blue shoes"),
("https://example.com/shoes?color=red", "Red shoes"),
]
def body_hash(text):
cleaned = " ".join(text.split()).lower()
return hashlib.sha256(cleaned.encode("utf-8")).hexdigest()
def base_url(url):
p = urlsplit(url)
return urlunsplit((p.scheme, p.netloc, p.path, "", ""))
df = pd.DataFrame(rows, columns=["url", "body_text"])
df["base"] = df["url"].map(base_url)
df["hash"] = df["body_text"].map(body_hash)
base_rows = df[df["url"] == df["base"]].set_index("url")
def compare(row):
if row["url"] == row["base"]:
return "base"
base = base_rows.loc[row["base"]]
if row["hash"] == base["hash"]:
return "identical"
if sorted(row["body_text"].lower().split()) == sorted(base["body_text"].lower().split()):
return "reordered"
return "different"
df["relation"] = df.apply(compare, axis=1)
print(df[["url", "relation"]])The relation column reads base, identical, reordered and different for the four rows.
identical(thesidURL) is an exact duplicate. A redirect or canonical to the base fixes it.reordered(thesortURL) has the same items in another order. A plain hash misses it, which is why near-duplicate detection exists.different(thecolorURL) is a real subset. Whether it deserves to be indexed depends on demand, not on the crawl alone.
On a real site, run this per parameter name and summarize the shares. If 98% of ref= URLs are identical, the parameter is a no-op.
Faceted navigation
Faceted navigation is the filter menu on a category page: color, size, brand, price. Each selection adds a parameter, or sometimes a path segment such as /shoes/red/. Two problems follow.
- Combinatorial growth. Facets combine, so
color,sizeandbrandtogether multiply the URL count. - Thin and empty pages. A narrow combination might list one product, or zero with a "no results" message that still returns status 200.
Not every facet is waste. A page for /running-shoes/red/ can match a real search query, and it can deserve its own title, heading and intro text. The working rule is to index the facets with demand and a distinct purpose, and to keep the rest out of the index and, ideally, out of the crawl path.
Check three things in the crawl for each facet group: how many internal links point to the URLs, what the canonical element says, and whether the page returns zero results with status 200.
Pagination
Pagination splits one long list across ?page=2, ?page=3 and so on. Page 2 shows different items from page 1, so it is not a duplicate of page 1 in the body text. The duplicate signals come from the template: the same title, the same meta description and the same intro paragraph.
Common errors:
- Canonical from page 2 to page 1. This tells search engines to ignore page 2, so products that appear only there can lose their link path. Each paginated page normally has a self-referencing canonical.
- Canonical from every page to a "view all" page. This only works if the view-all page loads fast and shows everything.
- Relying on
rel="next"andrel="prev". Google stated in 2019 that it no longer uses them. They are harmless, but they are not a fix. - Duplicate titles across pages. Flag them in the crawl. Adding "Page 2" to the title is a common minor fix.
Check also for pagination loops. If ?page=1 returns the same content as the base URL, that pair is an exact duplicate, and a page=1 link in the navigation should point to the base URL.
A decision path for each parameter
The following flow summarizes the questions to ask, in order.
Signal conflicts to check
The choice of signal matters as much as the decision. Each of the following conflicts shows up in crawls.
- robots.txt blocks the parameter and the page has a canonical or noindex. A crawler that cannot fetch the page never sees the canonical or noindex, so those signals do nothing. Blocked URLs can still be indexed from links alone.
- Canonical points to a URL that redirects, is noindexed or returns an error. Search engines will likely ignore the hint.
- Internal links point to parameter URLs while the canonical points to the clean URL. The site contradicts itself. Fix the links.
- Parameter URLs listed in the XML sitemap. The sitemap says "index this" while the canonical says otherwise.
Google retired its URL Parameters tool in 2022, so you cannot rely on a Search Console setting. The handling has to be in the site itself.
Edge cases
- Parameter order.
?a=1&b=2and?b=2&a=1are different URLs unless normalized. Sorting parameters, as in the previous chapter, merges them. - Case. Parameter values are case-sensitive on many servers, so
color=Redandcolor=redmay be separate pages that serve the same content. - Blank and repeated parameters.
?color=and?color=red&color=redare valid URLs that crawlers record. - Path-based facets. Facets in the path, such as
/shoes/red/size-9/, have no?, so a query-string classifier misses them. Classify by template as well. - Infinite spaces. Calendar links and endless "next" parameters can generate URLs without end. A crawl that hits its limit with these URLs in the queue is a sign of one.
Exercise
A crawl shows 4,000 URLs of the form /shoes?sort=price, /shoes?sort=name and so on across many categories. Hashing the body text finds no exact duplicates against the base URLs. Does that mean the pages are not duplicates, and what would you check next?
Show answer
No. Sorting changes the order of the same items, so the body hash differs even though the content is the same set of products. Compare the sets of items or use shingle similarity, as covered in the near-duplicate chapter. If the sets match, treat the sort URLs as near duplicates of the base URL, then check canonicals, internal links and sitemap entries before choosing a fix.
Exercise
Page 2 of a category has <link rel="canonical" href="https://example.com/shoes">, which is the URL of page 1. What is the risk, and what is the usual correction?
Show answer
The canonical asks search engines to treat page 2 as page 1, so the products that appear only on page 2 may lose their crawl path and index coverage. The usual correction is a self-referencing canonical on each paginated page, with distinct titles.