SmartPagination is a Laravel Blade component that simplifies pagination rendering and adds support for reverse pagination (descending page numbers). It’s designed to be flexible, SEO-friendly, and easy to customize.
Designed for blogs, news feeds, and any content that grows over time.
- Stable URLs — older content stays on the same page even as new items are added
- SEO-Friendly — search engines retain indexing without shifting links
- User-Centric — newest content always appears on the first page
- Blade component - easy to use in Blade templates with Bootstrap-ready markup
- Flexible Routing - supports custom URL patterns via
page-pattern - Preserves all other query parameters
- Reverse pagination support - show newest content first
SmartPagination allows you to generate clean, customizable,
and SEO-optimized pagination URLs for your applications.
Instead of relying on default query parameters like ?page=2,
you can define your own URL patterns such as /blog/page-2, /news-p3.html, or even /archive-4y.html.
Search engines prefer stable, predictable URLs. When paginated content (like blog posts, product listings, or news articles) grows over time, traditional pagination can cause older content to shift across pages — which may lead to:
- Duplicate indexing
- Loss of link equity
- Lower rankings for older content
With reverse pagination and custom URL patterns, you can ensure that:
- The first page always shows the newest content
- Older content remains accessible at the same URL
- Search engines consistently index the same pages over time
This improves crawl efficiency and preserves ranking signals for evergreen content.
You can define your own pagePattern using {page} as a placeholder:
| Pattern | Resulting URL (Page 2) |
|---|---|
page-{page} |
/blog/page-2 |
news-p{page}.html |
/news/news-p2.html |
archive-{page}y |
/archive-2y |
Reverse pagination is a powerful feature that ensures your newest content always appears on the first page, while older content stays anchored to its original URLs. This is especially useful for blogs, news feeds, changelogs, or any time-sensitive content.
With reverse pagination, the first page always shows the latest items, and older pages remain unchanged — making your site more SEO-friendly.
You have 100 articles, sorted by newest first (DESC), showing 10 per page.
| Display Page | Real Page | Articles Shown |
|---|---|---|
/news (page 1) |
page 1 | 91–100 (newest) |
/news/page-2 |
page 2 | 81–90 |
| ... | ... | ... |
/news/page-10 |
page 10 | 1–10 (oldest) |
Tomorrow you publish 10 more articles (total: 110):
| Display Page | Real Page | Articles Shown |
|---|---|---|
/news (page 1) |
page 1 | 101–110 (newest) |
/news/page-2 |
page 2 | 91–100 |
| ... | ... | ... |
/news/page-11 |
page 11 | 1–10 (still oldest) |
| Display Page | Real Page | Articles Shown |
|---|---|---|
/news (page 10) |
page 1 | 91–100 (newest) |
/news/page-9 |
page 2 | 81–90 always on page-9 |
| ... | ... | ... |
/news/page-1 |
page 10 | 1–10 (oldest) always on page-1 |
- New content appears on the first page
- Older content stays at the same URL
- Search engines retain stable indexing
- No shifting of articles across pages
Install via Composer:
composer require wnikk/smart-paginationFor basic usage, you can use the smartPaginate method on your Eloquent model.
This method will automatically handle pagination with the latest items first and generate reverse pagination links.
For example, if you have a Post model and want to paginate the latest posts on controller:
$posts = \App\Models\Post::orderByDesc('created_at')->smartPaginate(10, reverse: true);
$posts->withPath('/post', '/page-{page}.html'); In your Blade view (by default):
By default:
{{ $posts->links() }}Or your Blade custom view full version of params (SEO-friendly):
<x-smart-pagination
:paginator="$posts"
:reverse="true"
:page-pattern="post-p{page}.html"
:show-prev-next="true"
/>Publish Configuration
php artisan vendor:publish --tag=smart-pagination-configPublish Blade Views
php artisan vendor:publish --tag=smart-pagination-viewsMIT