Readable, hyphenated URLs
Lowercase, hyphenated, descriptive; no session IDs or stray params.
From seo-audit: URL Structure and Crawl Budget Issues.
Lint a URL
Edit the URL or title, or load a preset.
As typedBefore
RewrittenAfter
import { NextResponse, type NextRequest } from "next/server";
const JUNK = /^(sessionid|sid|jsessionid|phpsessid|utm_\w+|gclid|fbclid)$/i;
export function middleware(req: NextRequest) {
const url = req.nextUrl.clone();
const lower = url.pathname.toLowerCase();
let changed = lower !== url.pathname;
url.pathname = lower;
for (const key of [...url.searchParams.keys()]) {
if (JUNK.test(key)) { url.searchParams.delete(key); changed = true; }
}
return changed ? NextResponse.redirect(url, 301) : NextResponse.next();
}
Slug from a title
Type a title or pick a preset.
encodeURIComponentBad/blog/
slugify(title)Good
/blog/
const FILLER = new Set(["a", "an", "the", "and", "or", "of", "to", "in", "on", "for", "with", "at", "by", "from"]);
export function slugify(title: string, dropFiller = true) {
const words = title
.normalize("NFKD").replace(/[̀-ͯ]/g, "") // é → e
.toLowerCase()
.replace(/&/g, " and ")
.replace(/['’]/g, "")
.split(/[^a-z0-9]+/)
.filter(Boolean);
const kept = dropFiller ? words.filter((w) => !FILLER.has(w)) : words;
return (kept.length >= 2 ? kept : words).join("-");
}
Parameter explosion
Toggle parameters. Turn on sessionid last.
All variants crawlableBad
0 URLs for one page
?sort=…&sessionid=…ControlledGood
0 indexable URLs
rel="canonical"/running-shoes/red<link rel="canonical" href="https://example.com/running-shoes">
<link rel="canonical" href="https://example.com/running-shoes/red">
Set-Cookie: sid=ab9f…; Path=/; HttpOnly; Secure; SameSite=Lax
Why it matters, pros and cons
Why it matters
Parameters that don't change content fork one page into thousands of copies.
Pros
- Links and analytics add up in one place.
- Crawl budget goes to distinct pages.
- Session tokens stay out of shared links.
Cons
- Renaming live URLs needs 301s forever.
- Slugs drift when titles change; store them.
- Search and pagination parameters are legitimate.