<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Clozzi</title>
    <description>The latest articles on DEV Community by Clozzi (@clozziwear).</description>
    <link>https://dev.to/clozziwear</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4264650%2F75389f87-3220-453c-95b6-98987c8852fd.png</url>
      <title>DEV Community: Clozzi</title>
      <link>https://dev.to/clozziwear</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/clozziwear"/>
    <language>en</language>
    <item>
      <title>Find Keyword Cannibalization in Your Ecommerce Store With Python</title>
      <dc:creator>Clozzi</dc:creator>
      <pubDate>Thu, 26 Nov 2026 05:10:15 +0000</pubDate>
      <link>https://dev.to/clozziwear/find-keyword-cannibalization-in-your-ecommerce-store-with-python-1een</link>
      <guid>https://dev.to/clozziwear/find-keyword-cannibalization-in-your-ecommerce-store-with-python-1een</guid>
      <description>&lt;p&gt;If you build or maintain an online store, you have probably seen this problem: two pages on the same site compete for the same search query, and neither ranks well. This is called keyword cannibalization, and it is easy to introduce by accident when a catalog grows.&lt;/p&gt;

&lt;p&gt;The good news is that you can catch it automatically. In this post we will build a small Python script that reads a keyword-to-URL mapping and flags conflicts. I will use a medical apparel store as the example, since its catalog has a clear page hierarchy: a homepage, plus category pages for men, women, coats and caps.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Idea: One Primary Keyword per URL
&lt;/h2&gt;

&lt;p&gt;Every important page should own one primary keyword, plus a few close variants. If two URLs claim the same keyword, search engines have to guess which one to show.&lt;/p&gt;

&lt;p&gt;Broad terms belong on the homepage. For example, a store aimed at &lt;strong&gt;&lt;a href="https://clozzi.com" rel="noopener noreferrer"&gt;medical scrubs online&lt;/a&gt;&lt;/strong&gt; would target that location-based query on its homepage, because it describes the whole catalog. Narrower product terms belong on category pages, such as a &lt;strong&gt;&lt;a href="https://clozzi.com/collections/lab-coats" rel="noopener noreferrer"&gt;lab coat&lt;/a&gt;&lt;/strong&gt; collection for coat-related queries.&lt;/p&gt;

&lt;h2&gt;
  
  
  A clean mapping looks like this:
&lt;/h2&gt;

&lt;p&gt;Page    Primary keyword Secondary examples&lt;br&gt;
Homepage    medical scrubs  scrubs, scrub suit&lt;br&gt;
Lab coats   lab coat    white coat, doctor coat&lt;br&gt;
Men's scrubs    mens scrubs scrubs for men&lt;br&gt;
Women's scrubs  scrubs for women    ladies scrubs&lt;br&gt;
Caps    surgical caps   unisex scrub caps&lt;/p&gt;

&lt;p&gt;Doing this by eye works for 20 keywords. It does not work for 500, which is where a script helps.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Input File
&lt;/h2&gt;

&lt;p&gt;Most keyword tools export a spreadsheet. Save yours as a tab-separated file with these columns:&lt;/p&gt;

&lt;p&gt;Keyword URL Cluster Volume  KD&lt;br&gt;
scrubs  &lt;a href="https://example.com/" rel="noopener noreferrer"&gt;https://example.com/&lt;/a&gt;    homepage    8100    50&lt;br&gt;
lab coat    &lt;a href="https://example.com/collections/lab-coats" rel="noopener noreferrer"&gt;https://example.com/collections/lab-coats&lt;/a&gt;   Labcoats    1900&lt;br&gt;&lt;br&gt;
white coat  &lt;a href="https://example.com/collections/lab-coats" rel="noopener noreferrer"&gt;https://example.com/collections/lab-coats&lt;/a&gt;   Labcoats    720&lt;/p&gt;

&lt;h2&gt;
  
  
  The Script
&lt;/h2&gt;

&lt;p&gt;The tricky part is that "scrub suit" and "suit scrub", or "scrub" and "scrubs", are effectively the same query. So we normalize each keyword before comparing: lowercase it, strip a trailing "s" from longer words, and sort the words.&lt;/p&gt;

&lt;p&gt;python&lt;br&gt;
import csv&lt;br&gt;
from collections import defaultdict&lt;/p&gt;

&lt;p&gt;def normalize(keyword):&lt;br&gt;
    """Reduce a keyword to a comparable form: lowercase, singular, sorted."""&lt;br&gt;
    words = keyword.lower().strip().split()&lt;br&gt;
    words = [w[:-1] if w.endswith("s") and len(w) &amp;gt; 3 else w for w in words]&lt;br&gt;
    return " ".join(sorted(words))&lt;/p&gt;

&lt;p&gt;def find_conflicts(path):&lt;br&gt;
    groups = defaultdict(list)&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;with open(path, newline="", encoding="utf-8") as f:
    for row in csv.DictReader(f, delimiter="\t"):
        keyword = (row.get("Keyword") or "").strip()
        url = (row.get("URL") or "").strip()
        if not keyword or not url:
            continue  # skip unmapped keywords
        groups[normalize(keyword)].append((keyword, url))

# A conflict is one normalized keyword mapped to more than one URL
return {
    key: items
    for key, items in groups.items()
    if len({url for _, url in items}) &amp;gt; 1
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;if &lt;strong&gt;name&lt;/strong&gt; == "&lt;strong&gt;main&lt;/strong&gt;":&lt;br&gt;
    conflicts = find_conflicts("keywords.tsv")&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if not conflicts:
    print("No cannibalization found.")
else:
    for key, items in conflicts.items():
        print(f"\nConflict: '{key}'")
        for keyword, url in items:
            print(f"  - {keyword!r} -&amp;gt; {url}")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Run it with python check_keywords.py. If two pages target the same normalized keyword, you get output like this:&lt;/p&gt;

&lt;p&gt;Conflict: 'coat white'&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;'white coat' -&amp;gt; &lt;a href="https://example.com/collections/lab-coats" rel="noopener noreferrer"&gt;https://example.com/collections/lab-coats&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;'white coats' -&amp;gt; &lt;a href="https://example.com/collections/mens-lab-coats" rel="noopener noreferrer"&gt;https://example.com/collections/mens-lab-coats&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That tells you exactly which pages to fix: merge them, or give each a different primary keyword.&lt;/p&gt;

&lt;h2&gt;
  
  
  Extending the Script
&lt;/h2&gt;

&lt;p&gt;A few easy upgrades:&lt;/p&gt;

&lt;p&gt;Report unmapped keywords. Collect rows with a keyword but no URL, and print them as a to-do list.&lt;br&gt;
Use search volume. Sort conflicts by the Volume column so you fix the highest-traffic overlaps first.&lt;br&gt;
Catch partial overlaps. Compare word sets with Jaccard similarity to flag near-duplicates like "mens scrubs" and "best scrubs for men".&lt;br&gt;
Run it in CI. Fail the build when a new keyword creates a conflict, so the problem never reaches production.&lt;/p&gt;

&lt;h2&gt;
  
  
  On-Page Checklist for Each URL
&lt;/h2&gt;

&lt;p&gt;Once the mapping is clean, check each page:&lt;/p&gt;

&lt;p&gt;The primary keyword is in the title and the first 100 words&lt;br&gt;
There is one H1, with H2s covering related sub-topics&lt;br&gt;
Product images have descriptive alt text&lt;br&gt;
The meta description is unique and under 160 characters&lt;br&gt;
The page links to one or two relevant pages, not twenty&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Mistakes
&lt;/h2&gt;

&lt;p&gt;Targeting the same keyword on the homepage and a category page&lt;br&gt;
Stuffing keywords into product descriptions&lt;br&gt;
Ignoring low-volume long-tail terms with high intent&lt;br&gt;
Forgetting to re-run the check when you add a new collection&lt;br&gt;
Wrapping Up&lt;/p&gt;

&lt;p&gt;Keyword mapping is a spreadsheet and a few rules, and a short script keeps those rules honest as your catalog grows. Go broad on the homepage, specific on categories, and keep one primary keyword per URL.&lt;/p&gt;

&lt;p&gt;If you have a different way to detect cannibalization, or an improvement to the script, share it in the comments.&lt;/p&gt;

</description>
      <category>python</category>
      <category>seo</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
