Sub topic 2
Exact duplicates, near duplicates and thin pages
This chapter assumes you can read a crawl export (one row per URL, with status, title, body text and word count). It also assumes you know HTTP status codes and basic HTML. It defines three page problems that look similar in a crawl but need different detection methods and different fixes.
Three problems, three questions
Each problem asks a different question about a page.
- Exact duplicate: Does another URL serve the same main content, character for character, after whitespace and case are normalized?
- Near duplicate: Does another URL serve content that is mostly the same, with small differences such as a product color, a city name or a date?
- Thin page: Does this page offer little unique value for the intent it serves, regardless of what other pages say?
The first two compare a page with other pages. The third looks at one page alone. A page can be none of them, one of them, or several at once. An empty category page with no products is thin. If a hundred category pages show the same "No results found" text, they are also exact duplicates of each other.
| Problem | What you compare | Typical cause | Primary signal in a crawl |
|---|---|---|---|
| Exact duplicate | Normalized body text of two or more URLs | URL variants, parameters, printer versions, staging copies | Identical content hash |
| Near duplicate | Overlap of phrases between pages | Templated product or location pages, syndicated text, variants | High shingle similarity |
| Thin page | A page against its purpose and template | Empty listings, stub articles, tag pages, placeholder pages | Low main-content size, judged by template and intent |
Exact duplicates
Two URLs are exact duplicates when their extracted main content is identical after you remove differences that do not matter to a reader. You usually normalize whitespace and letter case before comparing.
The most common source is a URL variant: several addresses that return the same page. Examples are http and https, a trailing slash, an uppercase host name, or a tracking parameter such as utm_source. The server returns the same document, but a crawler records each address as a separate row. A later chapter covers URL normalization in detail. For now, remember that many "duplicate pages" are one page reached by several addresses.
Exact duplicates can also be real, separate documents that happen to share content. Examples are a staging site that is open to crawlers, a print-friendly version of an article, or two category paths that list the same products with the same copy.
Exact duplication is cheap to detect. You compute a fingerprint of the cleaned body text and group rows that share it. Hash only the main content and not the whole HTML. Page source often contains per-request values such as nonces, timestamps and session tokens, so two identical pages can produce different raw HTML hashes. The next chapters cover separating main content from boilerplate and hashing.
Near duplicates
Near duplicates share most of their content but differ in places. Think of two product pages for the same shoe in red and blue, or a "plumber in Leeds" page and a "plumber in York" page that differ only in the city name.
A hash cannot find them, because changing one word changes the whole hash. You need a similarity measure. The standard approach is to cut each page into overlapping word sequences called shingles and compare the two sets with the Jaccard similarity, which is shared shingles divided by all distinct shingles. A score of 1.0 means identical sets and 0.0 means no overlap.
Near duplication is a matter of degree, so every detection involves a threshold you choose. There is no universal "correct" cutoff. Where you set it depends on page length, how much boilerplate you removed, and what you plan to do with the result.
Short pages are sensitive to small changes. If a 15-word page changes one word, five-word shingles shift in two places. That alone drops the Jaccard score to about 0.69. On a 1,000-word page the same single-word change moves the score by less than 1%.
Thin pages
A thin page gives a visitor little that is useful or unique for the purpose the page serves. Thin does not mean short. A page that converts a currency, a contact page with an address and a map, and a product page with a clear photo, price and spec table can all be short and still do their job. A 600-word page of generic filler can be thin.
This is why a single word-count cutoff is a weak test. Word count is a screening metric that tells you where to look. The verdict comes from what the page is for. You judge thinness by:
- the template (product, category, article, tag, search result, profile)
- the intent a visitor brings to it
- how much unique main content it carries compared with its siblings
- whether it earns links, traffic or conversions
Thin pages often cluster in one template. An e-commerce site may have healthy product pages and thousands of empty filtered listings. Counting by template shows that shape immediately, and later chapters build on it.
A decision path
When you meet an odd row in a crawl, ask the questions in this order. Cheap, exact tests come first, and judgment-based tests come last.
The arrows from the duplicate boxes back to the thin test are deliberate. A duplicate can be thin as well, and you should check for both.
Classifying a pair of pages in code
The following script puts the first two tests together for a pair of texts. It is a teaching sketch. A real crawl needs the grouping approach you will build in later chapters, because comparing every pair of pages does not scale.
import hashlib
def clean(text):
return " ".join(text.split()).lower()
def shingles(text, k=5):
words = text.split()
if len(words) < k:
return {" ".join(words)} if words else set()
return {" ".join(words[i:i + k]) for i in range(len(words) - k + 1)}
def jaccard(a, b):
if not a and not b:
return 0.0
return len(a & b) / len(a | b)
def classify(text_a, text_b, near_threshold=0.6):
a, b = clean(text_a), clean(text_b)
hash_a = hashlib.sha256(a.encode("utf-8")).hexdigest()
hash_b = hashlib.sha256(b.encode("utf-8")).hexdigest()
if hash_a == hash_b:
return "exact", 1.0
score = round(jaccard(shingles(a), shingles(b)), 2)
if score >= near_threshold:
return "near", score
return "distinct", score
red = "Our red running shoes are lightweight and built for long road runs in all weather"
red_spaced = "Our RED running shoes are lightweight and built for long road runs\nin all weather"
blue = "Our blue running shoes are lightweight and built for long road runs in all weather"
empty = "Out of stock"
print(classify(red, red_spaced)) # ('exact', 1.0)
print(classify(red, blue)) # ('near', 0.69)
print(classify(red, empty)) # ('distinct', 0.0)Three details matter here.
- The first pair is exact because the hash is computed after cleaning. Without cleaning, the extra spaces, the newline and the capital letters would make the hashes differ.
- The second pair is near only because the threshold is 0.6. With a threshold of 0.8, the same pair would be "distinct". The threshold is a decision you make, not a property of the data.
- The "Out of stock" text is not a duplicate of anything here, but it is a thin-page candidate. This code cannot tell you that. You need the template and intent checks from the last part of the decision path.
Common errors
- Hashing raw HTML. Navigation, scripts and tokens make identical pages look different. Hash the extracted main content.
- Counting boilerplate as content. A page with 40 words of unique text and 400 words of header, footer and sidebar looks healthy by total word count. Measure the main content.
- Treating duplicate titles or meta descriptions as duplicate pages. Matching titles can point to a problem, but pages with the same title can have different content. Compare body content to confirm.
- Using one word-count cutoff for the whole site. It flags legitimately short pages and misses long but empty ones. Group by template first.
- Setting a similarity threshold once and never checking it. Read a sample of pairs just above and just below your cutoff. If the pairs on both sides look like the same kind of case, move the threshold.
- Assuming a duplicate is always a mistake. Some duplication is intended, for example a print version or a regional page with the same text. Check how the site already handles it before you change anything.
What comes next
The remaining chapters in this tutorial take each stage in turn. They cover normalizing URLs, handling parameters, separating boilerplate, exact and near matching, reading the signals the site already sends, and then choosing and checking fixes. Keep the three definitions from this chapter at hand, because each later chapter assumes you can tell the three problems apart.
Exercise
A crawl shows two 200-status URLs with the same title and a body-text word count of 12 each. Their cleaned body text differs by one word. Their content hashes differ. Which of the three categories could apply, and what do you check before choosing a fix?
Show answer
They are not exact duplicates, because the hashes differ. They may be near duplicates: with only 12 words, one changed word gives a low Jaccard score (the shingles overlap far less than on a long page), so check the score against a threshold and read the pair by eye. Both pages are also candidates for thin pages, because 12 words of body text is very little. Before choosing a fix, check the template and intent of each page, whether the 12 words are the main content or leftover boilerplate, and how the site already handles them (canonical, redirect, noindex). A shared title alone does not prove duplication.
Exercise
Why does hashing the full HTML of two pages often fail to find exact duplicates that a hash of the cleaned main content finds?
Show answer
Full HTML includes parts that differ per request or per URL, such as scripts, nonces, timestamps, tracking tokens and navigation state. Two pages with identical visible content then get different hashes. Hashing the extracted main content after normalizing whitespace and case removes those differences.