Sub topic 6
Group keywords into clusters
This chapter assumes you already have a list of keywords from seed research, a rough sense of search intent for each one, and basic comfort with CSV files and short Python scripts. You do not need to know how to build a full keyword map yet. Clustering is the step that turns a long keyword list into a short list of topics, and each topic is something one page can satisfy.
What a cluster is and why you need one
A keyword cluster is a group of keywords that one page can answer well. If you give each keyword its own page, you end up with many thin pages that compete with each other. If you put unrelated keywords on one page, the page answers none of them well.
Take the keywords "running shoes", "best running shoes" and "buy running shoes". Searchers who type these want roughly the same thing: a page that compares and sells running shoes. One category page can serve all three. "Trail running shoes" is different. Searchers want shoes built for off-road use, and the results look different. That keyword gets its own cluster and its own page.
The goal of clustering is to decide which keywords share a page and which do not. That decision feeds directly into the next chapters: assigning clusters to pages and detecting cannibalization.
Three ways to decide that keywords belong together
No single method is correct for every site. Most practitioners combine them.
Lexical grouping
Lexical grouping looks at the words themselves. Keywords that share a head term ("running shoes") or are small variations of each other (plural forms, word order, "best" and "top") are grouped.
- Strength: fast, free, and easy to do in a spreadsheet.
- Weakness: it ignores meaning. "Apple" the fruit and "apple" the company share a word but not a topic. It also misses synonyms, such as "sneakers" and "trainers", that share no words at all.
Semantic grouping
Semantic grouping uses meaning. You group "jogging shoes" with "running shoes" because you know they refer to the same product, even though the words differ. You can do this by hand on small lists, or with tools that use language models or word embeddings on large lists.
- Strength: catches synonyms and related phrasing.
- Weakness: a tool can say two phrases are about the same subject while searchers want different page types. "Running shoe size guide" and "running shoes" are semantically close, but one is informational and the other is commercial.
SERP-overlap grouping
SERP stands for search engine results page. SERP-overlap grouping asks the search engine directly. If two keywords return several of the same URLs in their top results, the engine treats them as the same topic, and one page can plausibly rank for both. If they return different URLs, the engine sees two topics.
- Strength: it reflects how the search engine actually behaves, including intent. It is the most reliable of the three.
- Weakness: it costs more. You need to collect the results for every keyword, and results change over time and vary by location and device.
A practical workflow is to group lexically first to cut the list down, then use SERP overlap to confirm the borderline cases.
Clustering with SERP overlap
The function below implements the overlap rule. It takes a dictionary that maps each keyword to the set of URLs ranking for it. A keyword joins an existing cluster if its results share at least min_shared URLs with the first keyword of that cluster.
def cluster_by_serp(serps, min_shared=3):
"""Group keywords whose search results share at least min_shared URLs.
serps maps each keyword to the set of URLs ranking for it.
A keyword joins the first cluster whose first keyword it overlaps with enough.
"""
clusters = []
for keyword, urls in serps.items():
for cluster in clusters:
if len(urls & serps[cluster[0]]) >= min_shared:
cluster.append(keyword)
break
else:
clusters.append([keyword])
return clusters
serps = {
"running shoes": {"a.com", "b.com", "c.com", "d.com"},
"best running shoes": {"a.com", "b.com", "c.com", "e.com"},
"trail running shoes": {"f.com", "g.com", "h.com", "i.com"},
}
print(cluster_by_serp(serps))
# [['running shoes', 'best running shoes'], ['trail running shoes']]Here "running shoes" and "best running shoes" share three URLs (a, b and c), which meets the threshold, so they join. "Trail running shoes" shares none, so it starts a new cluster.
How the algorithm behaves
- Each cluster is anchored to its first keyword. A new keyword is compared only with that anchor, not with every member.
- The order of keywords matters. Because a keyword joins the first matching cluster, a different input order can produce different clusters.
- A
for ... elseblock runs theelsebranch only when the loop finishes without abreak. That is how a keyword that matched no cluster starts a new one.
For this reason, sort your keywords by search volume, highest first, before you run it. The highest-volume keyword then becomes the anchor, which is usually the most natural primary keyword for the cluster.
Choosing the threshold
The min_shared value controls how aggressively keywords merge. There is no universal correct number, because it depends on how many results you collect.
| Setting | Effect | Risk |
|---|---|---|
| Low (1 or 2 shared URLs of the top 10) | Large clusters | Two different topics merge into one page |
| Medium (3 to 4 of the top 10) | Balanced clusters | Some borderline keywords are split or merged wrongly |
| High (5 or more of the top 10) | Small, tight clusters | One topic splits across several pages, which can cause cannibalization |
Start at 3 with the top 10 results and review the output by hand. Adjust it after you see which clusters look wrong.
Check intent inside each cluster
Overlap in results is a strong signal, but it is not proof. Before you accept a cluster, check that all of its keywords share one search intent, using the labels from the earlier chapter on intent.
A cluster that mixes intents is a warning sign. Look at "running shoes" (commercial) and "how to choose running shoes" (informational). If your tool merges them, the page you build will probably satisfy only one. Split the cluster, or keep both intents separate by giving each its own page.
Also check the page type that the results favour. If the top results for a cluster are all category pages, a blog post is unlikely to rank. If they are all guides, a product listing is unlikely to rank. The cluster should map to the page type that the results show.
Common errors
- Clustering by shared words only. "Apple pie recipe" and "apple watch price" share a word but nothing else. Check meaning and intent before merging.
- Letting one keyword join many clusters. Each keyword should belong to exactly one cluster. A keyword that appears in two clusters is a future cannibalization problem.
- Ignoring order. With the anchor method, input order changes the result. Sort by volume and keep the order fixed so the output can be repeated.
- Using stale results. Results change. A cluster built from results collected a year ago may no longer match what the engine shows. Record the collection date.
- Treating the tool output as final. Automated clusters are a first draft. A person who knows the business should review them.
- Making clusters too big. If a cluster has dozens of keywords and covers several sub-topics, one page cannot do it justice. Split it and link the pages together.
Naming the cluster and picking the primary keyword
Once a cluster is accepted, record two things for the next step:
- The primary keyword, which is the single phrase that best names the topic. Usually it is the highest-volume phrase that matches the cluster's main intent, but prefer the wording that searchers use most naturally.
- The supporting keywords, which are the remaining members. They go on the same page and appear in headings, body text and anchor text where they read naturally.
Store the result in a table you can load into the keyword map. A cluster output file might look like this:
cluster_id,primary_keyword,supporting_keywords,intent
1,running shoes,"best running shoes; buy running shoes",commercial
2,trail running shoes,"trail shoes; off-road running shoes",commercial
3,how to choose running shoes,"running shoe fit; running shoe size guide",informationalThe next chapters turn each row into a page assignment in the full keyword map.
Edge cases
- Very small clusters. A cluster with a single keyword is normal. Not every topic has variants.
- Keywords with almost no search volume. Group them with a larger cluster when the results overlap. Do not create a page for each one.
- Questions that overlap with a main topic. "What are the best running shoes for flat feet?" may overlap with a broader page, or may deserve a separate guide. Check the results. If the engine shows dedicated guides, make a separate cluster.
- Seasonal or local keywords. Results can differ by country, city or time of year. Collect results for the market you serve and note it in the map.
- Brand terms. Keywords that include a brand name often have their own results and intent, such as a navigational search. Keep them out of general clusters.
Exercises
Exercise
You run clusterbyserp with min_shared=3. "running shoes" and "jogging shoes" share only two URLs in their top results. What happens, and what would you check before deciding they are different topics?
Show answer
With min_shared=3, the function places them in different clusters, because two shared URLs is below the threshold. Before accepting that, check whether the threshold is too high for your data, whether both keywords have the same intent, and whether the two results lists show the same page type. If the results look alike but only barely miss the threshold, merge them by hand and note why.
Exercise
A tool puts "best running shoes" (commercial) and "how to choose running shoes" (informational) in one cluster. Why is this a problem, and what do you do?
Show answer
The two keywords have different intent, so one page will probably satisfy only one of them. Split the cluster into two. Give the commercial keyword to a category or comparison page and the informational keyword to a guide, then link the guide to the category page.