Permalinks

Unfold CMS uses a WordPress-style permalink system that lets you customize the URL structure for your content. Permalinks are managed through the admin panel and support date-based, category-based, and simple slug-based patterns.

Configuration

Configure permalink structures in Settings > SEO > Permalinks in the admin panel. You can set the post URL pattern, page URL pattern, and category base prefix.

Available Placeholders

Post Placeholders

Placeholder Output Example
%postname% Post slug getting-started-with-laravel
%year% 4-digit year 2025
%monthnum% 2-digit month 03
%day% 2-digit day 15
%category% Primary category slug tutorials

Page Placeholders

Placeholder Output Example
%pagename% Page slug about-us

Common Structures

Blog Posts

Structure Example URL Description
/blog/%postname%/ /blog/my-post/ Default — clean and simple
/%postname%/ /my-post/ Root-level slugs
/%year%/%postname%/ /2025/my-post/ Year-prefixed
/%year%/%monthnum%/%postname%/ /2025/03/my-post/ Year + month
/%year%/%monthnum%/%day%/%postname%/ /2025/03/15/my-post/ Full date
/%category%/%postname%/ /tutorials/my-post/ Category-prefixed

Pages

Structure Example URL
/page/%pagename%/ /page/about/
/%pagename%/ /about/

Categories

Categories use the category base setting:

https://example.com/category/technology
https://example.com/category/tutorials

Slug History & Redirects

When you change a post's slug, Unfold CMS automatically:

  1. Saves the old slug in the slug history table
  2. Creates a 301 redirect from the old URL to the new URL
  3. Preserves any search engine ranking the old URL had

This is powered by the HasSlugHistory trait on the Post model. Old slugs are automatically resolved and redirected.

How It Works

  1. A visitor requests /blog/old-post-title/
  2. The CMS checks if old-post-title is a current slug — it's not
  3. The CMS checks the slug history — finds a match pointing to the current post
  4. Returns a 301 redirect to /blog/new-post-title/

No manual redirect configuration is needed for slug changes.

Root-Level Slugs

If you use /%postname%/ as your post structure, posts are served at the root level (e.g., /my-post/). The permalink service detects root-level slug patterns and resolves them correctly, distinguishing between posts and pages.

Note: When using root-level slugs, ensure your post slugs don't conflict with system routes like /admin, /api, or /blog.

The PermalinkService handles URL generation and resolution:

  1. URL Generation — Converts a post model to its permalink URL based on the configured structure
  2. Route Pattern Conversion — Translates permalink patterns to Laravel route patterns
  3. Post Resolution — Given a URL, finds the matching post by slug and verifying date/category components
  4. Redirect Detection — Checks slug history for moved content

You can change the permalink structure at any time through the admin panel. When you change the structure:

  • Existing posts immediately use the new URL format
  • Old URLs return 404 (unless you set up manual redirects)
  • Sitemaps regenerate automatically with the new URLs

Warning: Changing permalink structure on an established site can affect SEO. Consider setting up redirects for your old URL patterns.