Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Sluggable Laravel Package

spatie/laravel-sluggable

Automatically generate unique slugs for Eloquent models on create/update. Supports collision suffixes, translatable slugs, and customizable slug options. Includes “self-healing” URLs that keep old links working via slug+id route keys and redirects.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • SEO & Content-Driven Features:

    • Enable SEO-friendly URLs for blog posts, articles, or product pages by auto-generating slugs from titles or custom fields.
    • Reduce manual effort in creating URL slugs, ensuring consistency and reducing human error.
    • Support multilingual content via translatable slugs (integrates with spatie/laravel-translatable), aligning with global expansion roadmaps.
  • Developer Productivity:

    • Build vs. Buy: Avoid reinventing slug-generation logic (e.g., custom observers, model events, or middleware). The package handles uniqueness, collisions, and edge cases out of the box.
    • Consistency: Standardize slug generation across the codebase, reducing technical debt from ad-hoc implementations.
    • Self-Healing URLs: Future-proof URL structures by combining slugs with IDs (e.g., /posts/my-slug-123), eliminating broken links when content is renamed. Critical for content-heavy apps (e.g., CMS, e-commerce).
  • Scalability & Maintenance:

    • Dynamic Slugs: Use closures in getSlugOptions() to generate slugs from complex logic (e.g., combining author names + titles) or skip generation for drafts.
    • Scoped Uniqueness: Prevent slug conflicts across tenants/multi-tenant systems by scoping uniqueness checks (e.g., tenant_id).
    • Custom Suffixes: Replace default numeric suffixes (e.g., -1, -2) with UUIDs or hashed values for niche use cases (e.g., analytics tracking).
  • Roadmap Alignment:

    • AI/Developer Experience: Leverage the bundled Laravel Boost skill to scaffold sluggable models via AI, accelerating onboarding for junior devs.
    • Localization: Prioritize translatable slugs if expanding to multiple languages (e.g., /es/mi-articulo, /en/my-article).

When to Consider This Package

  • Look Elsewhere If:

    • Your slugs are static and user-provided (e.g., SKUs, fixed codes). Use a validation rule instead of auto-generation.
    • You need slugs for non-Eloquent models (e.g., API resources, collections). Consider a standalone utility like Str::slug() or a custom service.
    • Your slugs require complex business logic (e.g., slugs derived from external APIs or real-time data). The package’s attribute/trait system may not suffice; build a custom observer or service.
    • You’re using Laravel Octane or high-performance modes where attribute-based magic methods (e.g., #[Sluggable]) introduce overhead. Benchmark first.
    • Your team prefers explicit over convention and wants full control over slug generation (e.g., manual triggers, event-based updates). The trait’s getSlugOptions() offers flexibility, but some may prefer raw SQL or custom logic.
  • Consider This Package If:

    • You’re building a content platform (blogs, CMS, e-commerce) where SEO-friendly URLs are critical.
    • You need automated, unique slugs with minimal boilerplate (e.g., #[Sluggable] attribute).
    • Your app handles multi-tenancy or localization, and you want scoped/uniqueness or translatable slugs.
    • You prioritize developer velocity and want to avoid reinventing slug-generation logic.
    • You need self-healing URLs to prevent broken links when content is edited.

How to Pitch It (Stakeholders)

For Executives (Business/Strategy)

"This package automates the creation of SEO-friendly URLs for our content (e.g., blog posts, products) by generating clean slugs from titles or custom fields. For example, a post titled ‘How to Build a Laravel App’ becomes /how-to-build-a-laravel-app. Key benefits:

  • Reduce manual work: No more manually crafting slugs or fixing broken links when content is renamed.
  • SEO boost: Search engines favor readable URLs, improving organic traffic.
  • Scalability: Supports multilingual content and multi-tenant systems with minimal effort.
  • Future-proof: Self-healing URLs ensure links stay intact even if content is edited. It’s a low-risk, high-impact tool that aligns with our roadmap for content growth and localization. The MIT license and Spatie’s reputation ensure reliability."

For Engineering (Technical)

"spatie/laravel-sluggable provides a battle-tested solution for Eloquent slug generation with these advantages:

  • Zero Boilerplate: Add #[Sluggable] to a model, and it handles uniqueness, collisions, and even self-healing URLs (slug-ID combos like /posts/my-slug-123).
  • Flexibility:
    • Use attributes for simple cases (e.g., #[Sluggable(from: 'title')]).
    • Use the HasSlug trait for advanced logic (closures, scoped uniqueness, custom suffixes).
  • SEO & UX: Self-healing URLs prevent 404s when content is renamed, and translatable slugs support global audiences.
  • Performance: Optimized for Laravel, with Laravel Boost integration for AI-assisted scaffolding.
  • Maintenance: Actively maintained (last release: 2026), with clear docs and community support. Alternatives like custom observers or manual slugging add technical debt. This package is a build vs. buy win—it’s lightweight, extensible, and saves dev time."

For Product Managers (Use Cases)

"This package directly supports:

  1. Content Platforms: Auto-generate slugs for blog posts, articles, or product pages (e.g., /blog/laravel-tips).
  2. Localization: Translatable slugs for multilingual sites (e.g., /es/mi-articulo).
  3. Multi-Tenancy: Scoped slug uniqueness to avoid conflicts across tenants.
  4. Self-Healing URLs: Critical for apps where content is frequently edited (e.g., CMS, news sites).
  5. Developer Experience: Reduce onboarding time with Laravel Boost AI support and consistent conventions. Example pitch for a blog feature:

‘By implementing this, we can ensure every post has a clean, SEO-friendly URL automatically—no more manual slug management or broken links when editors rename posts.’"

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codraw/framework-extra-bundle
codraw/messenger
codraw/security
codraw/mailer
codraw/contracts
codraw/profiling
codraw/dependency-injection
codraw/tester
codraw/core
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony