modern seo

Write clean, readable URL slugs

MetricSpot checks the URL slug for length, separators, and whether it reads like real words. Clean slugs (/seo-guide) outperform IDs (/page?id=123) for clicks and indexing.

What this check does

Parses the URL of the page being audited and inspects the last path segment (the “slug”). The check fails when the slug is:

  • A numeric or hashed ID/posts/47391, /p?id=a8f3e2b0.
  • Too long — over 60 characters.
  • Stuffed with underscores instead of hyphens — /seo_guide_for_2026_complete.
  • Mostly stop words/what-is-the-best-way-to-do-x.
  • All caps or mixed case/SEO-Guide, /seoGuide.
  • Contains spaces or special characters/SEO Guide.html, /SEO%20Guide.

Why it matters

Clean slugs aren’t just aesthetic — they affect click-through, ranking, and shareability in measurable ways.

  • Click-through. Studies consistently find that descriptive URLs in search results get 10–30% more clicks than IDs. The slug shows next to the title in every SERP — it’s part of your headline.
  • Ranking signal. Google has confirmed the URL slug is a (minor) ranking factor. Words in the slug that match the user’s query get bolded, like the title and description.
  • Shareability. A URL someone can read is a URL someone can remember and tell a colleague. metricspot.com/docs/enable-hsts/ is shareable; metricspot.com/docs/?id=42891 is not.
  • AI extraction. ChatGPT, Perplexity, and Google AI Overviews quote slugs in citations. A clean slug reads as a real source; an ID reads as machine-generated.

How to fix it

Use lowercase, hyphen-separated, keyword-rich slugs under ~60 characters.

Good:

/docs/enable-hsts/
/blog/how-https-works/
/pricing/
/products/wireless-earbuds-pro/

Bad:

/docs/47391/                          (ID, no meaning)
/Docs/Enable_HSTS/                    (caps, underscores)
/the-complete-2026-guide-to-enabling-hsts-on-your-website-step-by-step/   (too long)
/docs/?id=hsts&v=2&from=blog          (query params for content URLs)

Rules.

  • Hyphens, not underscores. Google treats hyphens as word boundaries; underscores aren’t. enable-hsts matches “enable HSTS”; enable_hsts reads as one mashed-up word.
  • Lowercase. Some servers treat /Docs/Enable-HSTS/ as a different URL from /docs/enable-hsts/ — duplicate content, split signals. Force everything lowercase at the redirect layer.
  • Drop stop words selectively. /how-https-works/ is fine. /the-best-way-to-enable-https-on-nginx-quickly/ reads like SEO from 2012.
  • No file extensions. /about.html, /post.php. Strip them; redirect old URLs with extensions to the clean version.
  • Stable URLs. Once a slug is published and indexed, changing it costs you backlinks. Pick a good slug the first time. If you must change one, set a 301 redirect from the old slug.

WordPress — Settings → Permalinks → “Post name” gives you clean slugs by default. For each post, edit the slug field in the URL meta-box before publishing. If you change a published slug, install Redirection so the old URL 301s automatically.

Astro — file-based routing makes slugs explicit. Name src/pages/docs/enable-hsts.astro and you get /docs/enable-hsts/. Done.

Next.js — App Router uses folder names as segments. app/docs/enable-hsts/page.tsx/docs/enable-hsts/. For dynamic routes, generate slugs at build time from a content source:

// app/blog/[slug]/page.tsx
export async function generateStaticParams() {
  const posts = await getPosts();
  return posts.map(post => ({ slug: post.slug }));
}

Generate slugs programmatically:

function slugify(title: string): string {
  return title
    .toLowerCase()
    .normalize("NFD").replace(/[̀-ͯ]/g, "") // strip accents
    .replace(/[^a-z0-9\s-]/g, "")                     // drop punctuation
    .trim()
    .replace(/\s+/g, "-")                              // spaces → hyphens
    .replace(/-+/g, "-")                               // collapse repeated hyphens
    .slice(0, 60);                                     // cap length
}

slugify("Enable HSTS on nginx & Apache");
// → "enable-hsts-on-nginx-apache"

Don’t change published slugs. If you must — domain migration, rebrand — set up a 301 redirect from the old slug to the new one and add it to your sitemap. See Keep redirect chains short so the 301s collapse to a single hop.

Frequently asked questions

Should I include the date in blog post slugs?

Optional. /blog/2026/05/enable-hsts/ makes evergreen content look dated when a user clicks it three years later. /blog/enable-hsts/ doesn’t. If you write a lot of timely news content, dates can help; for evergreen guides, drop them.

What about non-English slugs?

For pages targeting a specific language, use that language’s words. /es/docs/activar-hsts/ ranks better in Spanish search than /es/docs/enable-hsts/. Strip accents (activar, not activación) — Google still matches, and accented characters break in some clients.

Should the slug match the title exactly?

No — close, not identical. The title is a complete sentence with stop words and punctuation; the slug is the keyword-dense core. Title: “How to enable HSTS on nginx and Apache (with code samples)”. Slug: /enable-hsts/ or /enable-hsts-on-nginx-apache/.

Sources

Last updated 2026-05-11