Product URLs & Database Architecture
Build SEO-friendly product catalogs that scale from hundreds to millions of products
E-Commerce Foundation: Product pages are the money pages of any online store. This guide covers URL structure, handling variants, managing product lifecycle, and database design that supports SEO at scale.
Slug Generation Best Practices
Transform product names into clean, SEO-friendly URLs
A slug is the URL-friendly version of a product name. Good slug generation is the foundation of product SEO.
// Slug transformation example
Input: "Nike Air Max 90 - Men's Running Shoe"
Output: "nike-air-max-90-mens-running-shoe"
// Steps:
1. Convert to lowercase
2. Remove special characters (keep letters, numbers, spaces)
3. Replace spaces with hyphens
4. Remove consecutive hyphens
5. Trim hyphens from start/end
Good Slug Practices
- ✓ Keep important keywords at the start
- ✓ Use hyphens (not underscores) as separators
- ✓ Make them readable by humans
- ✓ Keep them reasonably short (3-5 words ideal)
- ✓ Remove filler words (the, a, an, of)
Avoid These Mistakes
- ✗ Using underscores instead of hyphens
- ✗ Including stop words unnecessarily
- ✗ Overly long URLs (10+ words)
- ✗ Special characters (%20, &, ?, =)
- ✗ UPPERCASE or MixedCase slugs
URL Pattern Comparison
SEO-Friendly URLs
/products/nike-air-max-90-red✓ Descriptive, readable, keywords visible
/shoes/running/nike-air-max-90✓ Category hierarchy, contextual navigation
/brand/nike/air-max-90✓ Brand navigation, logical structure
Poor URL Patterns
/products?id=12345&color=red✗ No keywords, unmemorable, looks temporary
/p/cat3/prod8273✗ Cryptic IDs, no context, zero SEO value
/Nike_Air_Max_90%20RED✗ Mixed case, underscores, URL encoding
URL Length & Keyword Considerations
Balance is key: URLs should be descriptive but not stuffed with keywords. Google values user experience and readability over keyword density in URLs.
Ideal Length
• 3-5 words in slug
• 50-60 characters total
• Easy to read & remember
/running-shoes-women
Acceptable
• 5-8 words in slug
• 60-100 characters
• Still manageable
/nike-air-max-90-white-red
Too Long
• 10+ words
• 100+ characters
• Looks spammy
/best-nike-running-shoes...
Keyword Placement Tips
- • Most important keywords first: "running-shoes-nike" better than "nike-offers-running-shoes"
- • Use category paths: /shoes/running/nike-air-max (keywords in path segments)
- • Avoid keyword stuffing: Don't repeat words (nike-nike-shoes-nike)
- • Natural language wins: Write for humans, not search engines
Technical Implementation Notes
// Database schema for products
products:
- id (primary key)
- name ("Nike Air Max 90")
- slug ("nike-air-max-90")
- description
- status (active, discontinued, out_of_stock)
// Always query by slug, not ID
SELECT * FROM products WHERE slug = 'nike-air-max-90'
Uniqueness Constraint
Slugs must be unique in your database. If duplicate detected:
- • Append variant: "air-max-90-red", "air-max-90-blue"
- • Append number: "air-max-90-2", "air-max-90-3"
- • Use product ID: "air-max-90-12345"
Slug History Table
When product names change, keep old slugs for redirects:
product_slug_history:
- product_id
- old_slug
- created_at
- product_id
- old_slug
- created_at