url-canonicalization

Enforce URL canonicalization with middleware redirects and URL-building helpers in Next.js apps.

2|Updated Apr 9, 2023
One-click install
npx skills add https://github.com/Esdeveniments/esdeveniments-frontend --skill url-canonicalization
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: url-canonicalization
Source: https://github.com/Esdeveniments/esdeveniments-frontend/tree/main/.github/skills/url-canonicalization
Command: npx skills add https://github.com/Esdeveniments/esdeveniments-frontend --skill url-canonicalization

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Enforce URL canonicalization rules to prevent SEO issues and costly dynamic rendering in listing pages.

Core Features & Use Cases

  • Canonical URL generation using helpers to ensure consistent paths across routes.
  • Middleware-based redirects to canonical forms and date/category segmentation.
  • SEO optimization by preserving essential query params while avoiding dynamic pages.

Quick Start

Configure the canonicalization middleware in proxy.ts, use buildCanonicalUrl and related helpers in your routes, and test a few routes to verify correct redirects.

Frequently Asked Questions about url-canonicalization

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I enforce URL canonicalization in Next.js to prevent duplicate content issues?

Middleware-based canonical redirects intercept non-canonical requests and forward them to the standard URL path. This Next.js middleware approach preserves essential query parameters while stripping dynamic variants that cause duplicate content issues.

How do I handle canonical URLs for Next.js segment-based routes with date and category rules?

Canonical URL generation for date and category segments uses dedicated helpers to enforce consistent path structures across listing pages. This prevents dynamic rendering of invalid date or category combinations by redirecting them to their canonical forms.

What is the best way to manage query parameters during URL canonicalization without breaking pagination?

To manage query parameters without breaking functionality, the canonicalization workflow preserves essential variables like pagination cursors while discarding dynamic or tracking parameters. This ensures the canonical URL remains SEO-safe without losing necessary page state.

Why does dynamic rendering increase costs on Next.js listing pages and how do canonical redirects help?

Canonical redirects reduce dynamic rendering costs by funneling duplicate URL variants to a single static canonical path. By limiting the number of unique URLs that require on-demand generation, the middleware prevents unnecessary server compute usage on listing pages.

Do I need Next.js middleware to implement proxy-based canonical redirects?

Next.js middleware is required to implement proxy-based canonical redirects because it intercepts requests at the edge before full application routing. Configuring the middleware in proxy.ts allows the canonicalization rules to execute redirects early in the request lifecycle.

How do I add SEO headers for canonical URLs in a Next.js application?

SEO headers for canonical URLs are added by generating standard link tags and injecting them into the Next.js page metadata. The Skill includes SEO header generation in its workflow to reinforce the canonical signals sent by the middleware-based redirects.