Laravel

    Laravel Canonical URLs and Pagination SEO

    Implement reliable canonical URLs in Laravel and handle paginated, filtered and sorted listings without creating duplicate content or wasting crawl budget.

    Published July 15, 202611 min readBy Mazam Khalid
    On this page

    Laravel applications rarely have rendering problems. What they do have is URL multiplication: one listing route can produce thousands of crawlable variants through pagination, sorting, filtering and tracking parameters. Canonicalisation is how you keep that under control.

    A canonical helper you can trust

    Do not build the canonical from request()->fullUrl() — that bakes every stray parameter into the tag. Derive it from the route:

    // app/Support/Seo.php
    public static function canonical(?array $keep = ['page']): string
    {
        $base = url()->current();               // no query string
        $query = collect(request()->query())
            ->only($keep ?? [])
            ->filter(fn ($v) => $v !== '' && $v !== '1')
            ->sortKeys()
            ->all();
    
        return $query ? $base . '?' . http_build_query($query) : $base;
    }

    Three behaviours matter here: the base URL has no parameters, only an explicit allowlist survives, and page=1 is dropped so the first page and the bare listing URL do not compete. Output it once in the layout so no template can forget it.

    Enforce one URL form at the edge. Decide on http vs https, www vs non-www, trailing slash vs none, and lowercase paths — then enforce it with a single server-level redirect. Canonical tags should not be compensating for inconsistent routing.

    Pagination

    Laravel's paginator produces ?page=N by default. Handle it like this:

    • Self-canonical every page. /products?page=3 canonicalises to itself.
    • Keep page 1 clean. /products?page=1 should redirect to or canonicalise to /products, never both existing as indexable.
    • Make the links crawlable anchors. Buttons that fire JavaScript hide the deeper pages from discovery.
    • Differentiate titles — appending "– Page 3" prevents identical titles across dozens of URLs.
    • Do not noindex deep pages. A noindexed page still passes links initially, but Google eventually treats long-term noindex as nofollow, orphaning the items only listed there.
    • Cap infinite scroll with real paginated URLs behind it so every item is reachable without JavaScript.

    Filters and sorting

    Not every filter deserves a URL. Classify them:

    Parameter typeExampleTreatment
    Presentation only?sort=price_desc, ?view=gridCanonical to the clean URL; do not link with crawlable anchors
    Tracking?utm_source=, ?gclid=Canonical to the clean URL; never in sitemaps or internal links
    Content-defining, low demand?colour=teal&size=xlCanonical to the clean URL; block deep combinations from crawling
    Content-defining, real demand"waterproof walking boots"Promote to a clean indexable route with unique copy

    The last row is the one that earns traffic. If a filtered state matches how people search, give it a static route such as /boots/waterproof, its own heading, its own description, and a place in the sitemap — rather than leaving it as a parameter Google is told to ignore.

    Canonical is a hint, not a directive. If your internal links, sitemap and redirects point at parameterised URLs while the canonical points elsewhere, Google may choose the URL your links favour. Signals must agree.

    Route-model binding and slug changes

    When a slug changes, the old URL should redirect rather than 404. Keep slug history and resolve it in the binding:

    public function show(string $slug)
    {
        $product = Product::where('slug', $slug)->first();
    
        if (! $product) {
            $historic = SlugHistory::where('slug', $slug)->firstOrFail();
            return redirect()->route('products.show', $historic->product->slug, 301);
        }
    
        return view('products.show', compact('product'));
    }

    This one pattern prevents most of the 404 accumulation that catalogues suffer over years of editorial changes — see fixing 404 errors for the wider workflow.

    Verification checklist

    1. Crawl the application and group URLs by canonical value; no cluster should be unexpectedly large.
    2. Confirm no page canonicalises to the homepage unless it is the homepage.
    3. Check ?page=1, uppercase paths, and trailing-slash variants resolve to a single form.
    4. Confirm paginated pages self-canonicalise and are reachable as plain anchors.
    5. Check the sitemap contains only canonical URLs.
    6. Inspect a filtered URL in Search Console and confirm the Google-selected canonical matches your declared one.

    Put this into practice

    Move from diagnosis to implementation with a focused engagement for your stack.

    Laravel SEO Services

    Frequently asked questions

    Should page 2 canonicalise to page 1?
    No. Each paginated page should self-canonicalise. Canonicalising page 2 to page 1 tells Google page 2 is a duplicate, and the items only listed there may never be discovered through that path.
    Do rel=next and rel=prev still matter?
    Google stopped using them as an indexing signal, but they remain valid HTML and cost nothing. Prioritise self-canonicals and crawlable pagination links instead.
    How should I handle sort and filter parameters?
    Canonicalise them to the clean listing URL, avoid linking to them with crawlable anchors where they add no search value, and promote to a real indexable URL only the filters with genuine demand.

    Laravel app generating duplicate URLs?

    Filters, sorts and pagination multiply quickly in Laravel listings. I implement the canonical and crawl rules that keep the index clean without hiding pages that should rank.

    Mazam Khalid — Technical SEO & AI Search Specialist

    Mazam Khalid works across technical SEO, Google Search Console, indexing and crawl optimization, AI Search Optimization, GEO/AEO, structured data, Core Web Vitals, WordPress, Shopify, Laravel, React and website performance. He also works on Google Ads, Meta Ads, analytics and conversion tracking where technical implementation affects search visibility and lead generation.

    Chat on WhatsApp