Slug

المعرّف النصي (Slug)

Beginnerprogramming1 min read
url slugpermalinkurl-friendly stringkebab caseseo slug

Definition

A URL-friendly string derived from a title, using lowercase letters and hyphens instead of spaces and special characters.

سلسلة صديقة لعناوين URL مشتقة من عنوان، تستخدم أحرفًا صغيرة وشرطات بدلاً من المسافات والأحرف الخاصة.

Why It Matters

Every glossary term in 404Fault has a slug that is both its Firestore document ID and its URL path. The slug 'firebase-authentication' is what appears in /glossary/firebase-authentication and what the KG API looks up.

كل مصطلح قاموس في 404Fault له slug يكون في آنٍ معًا ID مستند Firestore ومسار URL. slug 'firebase-authentication' هو ما يظهر في /glossary/firebase-authentication وما يبحث عنه KG API.

Full Definition

A slug is a URL-safe identifier created by converting a string to lowercase, replacing spaces with hyphens, and removing special characters. 'Firebase Authentication' → 'firebase-authentication'. 'RAG (Retrieval-Augmented Generation)' → 'retrieval-augmented-generation'. Slugs appear in URLs (/glossary/firebase-authentication) and serve as stable, human-readable identifiers in databases. 404Fault uses slugs as Firestore document IDs for glossary terms.
Slug معرّف آمن لعناوين URL يُنشأ بتحويل سلسلة إلى أحرف صغيرة واستبدال المسافات بشرطات وإزالة الأحرف الخاصة. 'Firebase Authentication' → 'firebase-authentication'. تظهر في عناوين URL (/glossary/firebase-authentication) وتُعمل كمعرّفات مستقرة في قواعد البيانات.

Example Usage

function buildSlug(name: string): string { return name.toLowerCase().trim().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, ''); }

function buildSlug(name: string): string { return name.toLowerCase().trim().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, ''); }

Knowledge Graph

Avoid these mistakes when using Slug:

1

Changing a slug after it's published — breaks existing URLs and search engine ranking

2

Not normalizing aliases to the canonical slug — causes duplicate content issues

Sign in to unlock guided AI explanations from AI Teacher.

Generate a Prompt

Copy this prompt and use it directly with any AI model — no setup needed.

Ready-to-Use Prompt
Help me build a project using Slug.

Explain:
1. What is Slug and why it matters
2. The core architecture and required tools
3. Step-by-step implementation plan
4. Common mistakes to avoid: Changing a slug after it's published — breaks existing URLs and search engine ranking, Not normalizing aliases to the canonical slug — causes duplicate content issues
5. Best practices and production tips

Official Resources