At some point in every Laravel developer’s journey, managing routes in web.php
gets tedious—especially when scaling a site with multiple static or dynamic pages.
Perhaps you’ve felt the pain of cluttered route files, complex naming conventions, and duplicate route definitions.
Problem solved: Laravel Folio. It’s a new file-based page routing system introduced in Laravel 11 that simplifies routing like never before. Whether you’re building static landing pages or dynamic blog posts, Laravel Folio makes it clean, organized, and lightning-fast.
In this step-by-step guide, you’ll learn how to build static and dynamic pages with Laravel Folio—the right way. You’ll also discover key tips to make your app SEO-friendly and scalable for real-world production.
Blog Outline
- What is Laravel Folio?
- Benefits of Using Laravel Folio
- Prerequisites & Setup
- How to Install Laravel Folio
- Create Static Pages with Laravel Folio
- Create Dynamic Pages with Laravel Folio
- Add Route Parameters and Slugs
- SEO Tips for Static and Dynamic Pages
- Common Errors & Fixes
- Final Thoughts
What is Laravel Folio?
Laravel Folio is a new file-based routing system that allows you to create pages by simply placing Blade files in specific directories—no need to define each route manually in web.php
. It’s inspired by Next.js and other modern frameworks.
With Folio, Laravel scans your resources/views/pages
directory and automatically generates routes based on file structure.
Benefits of Using Laravel Folio
- Zero route configuration: No need to define routes manually
- Cleaner codebase: File structure maps directly to routes
- Supports dynamic routing: Slugs, parameters, and even nested pages
- Lightweight: No extra routing overhead
- Improved development speed: Rapid prototyping and feature scaling
Prerequisites & Setup
Before diving in, make sure you have:
- PHP 8.2 or higher
- Laravel 11 installed
- Composer
- A working Laravel project
If not, you can quickly create one:
composer create-project laravel/laravel folio-demo
cd folio-demo
How to Install Laravel Folio
Laravel Folio is not included by default, so install it via Composer:
composer require laravel/folio
Next, publish the Folio service provider and configuration:
php artisan folio:install
You’ll see a new directory:
resources/views/pages/
This is where the magic happens.
Now register Folio in your routes/web.php
:
use Laravel\Folio\Folio;
Folio::route(public_path('resources/views/pages'));
Create Static Pages with Laravel Folio
Static pages like about
, contact
, or terms
are easy.
- Go to
resources/views/pages/
- Create a file called
about.blade.php
:
<!-- resources/views/pages/about.blade.php -->
@extends('layouts.app')
@section('content')
<h1>About Us</h1>
<p>We are passionate about Laravel development!</p>
@endsection
- Visit
http://localhost:8000/about
—no route needed!
You can create as many static pages as you like. Just follow the pattern.
Create Dynamic Pages with Laravel Folio
Dynamic pages need parameters. Let’s create a blog page for posts:
- Create a new file:
resources/views/pages/posts/[slug].blade.php
Yes, wrap the dynamic part in square brackets [slug]
.
<!-- resources/views/pages/posts/[slug].blade.php -->
@extends('layouts.app')
@section('content')
<h1>{{ ucwords(str_replace('-', ' ', $slug)) }}</h1>
<p>This is a dynamic post page for "{{ $slug }}".</p>
@endsection
Now visit:
http://localhost:8000/posts/laravel-folio-intro
And it works! Laravel automatically passes slug
as a variable.
Add Route Parameters and Slugs
You can even nest parameters:
resources/views/pages/posts/[category]/[slug].blade.php
Access the variables in Blade:
<h2>{{ $category }} > {{ $slug }}</h2>
This lets you create complex URLs like:
/posts/laravel/folio-routing
SEO Tips for Static & Dynamic Pages
To make your Folio-powered pages SEO-optimized:
- Use clean and readable slugs (
[slug]
instead of[id]
) - Add proper
<title>
,<meta>
tags in your Blade layouts - Implement canonical URLs
- Use Laravel’s built-in route caching:
php artisan route:cache
- For dynamic content, store metadata in the database and pass it to the view via a global view composer or middleware
Bonus: Laravel Folio works great with Laravel Volt and Livewire for reactive SEO-friendly components.
Common Errors & Fixes
Error: Folio directory not found
Fix: Ensure you ran php artisan folio:install
Error: Blade variables undefined
Fix: Remember to use square brackets in filenames ([slug].blade.php
)
Error: Styles/scripts not loading
Fix: Make sure you’re extending a layout that includes them (@vite
or @stack
)
Final Thoughts
Laravel Folio is a must-know feature for any modern Laravel developer. It eliminates route boilerplate and gives you a simple, scalable approach to building both static and dynamic pages.
Whether you’re crafting a small landing page or a full-blown blog with categories and slugs, Laravel Folio will streamline your development and improve code maintainability.
Try it out today—and you might never go back to writing routes manually again.