Canonical tag skill

When the user wants to configure canonical URLs, fix duplicate content, or consolidate URL signals.

by kostja94·MIT license·★ 1,006 Stars on the repo·GitHub ↗

Use now

Files of Canonical tag

kostja94/main1 file shown
SKILL.md
Show the full text125 lines

SEO Technical: Canonical

Guides canonical tag configuration to consolidate duplicate content and declare preferred URLs.

When invoking: On first use, if helpful, open with 1–2 sentences on what this skill covers and why it matters, then provide the main output. On subsequent use or when the user asks to skip, go directly to the main output.

Scope (Technical SEO)

  • Duplicate site versions: HTTPS vs HTTP; www vs non-www; trailing slash (/page vs /page/) — choose one, 301 redirect others
  • Duplicate content: Canonical tags; consolidate and 301 to preferred URL
  • HTTPS: SSL/TLS; secure connection; ranking signal since 2014

Initial Assessment

Project context: Read root contextus.md when present and load only the modules relevant to this task. Without Contextus, use available project material or user-provided facts and ask for missing information; do not create a parallel context system.

Identify:

  1. Site URL: Base domain
  2. Duplicate scenarios: Multi-language, query params, pagination, alternate URLs
  3. Framework: Next.js, React, static, etc.

Canonicalization Methods (Choose by Scenario)

Method When Strength
301 redirect Preferred; server can redirect Strongest — permanent redirect
Canonical tag Cannot redirect (e.g. params, pagination) Strong — HTML signal
robots.txt Block non-canonical paths Weak — advisory only

Use 301 for HTTP→HTTPS, www variants, trailing slash. Use canonical for params, pagination, UTM.

HTTPS & Security

HTTPS is a ranking signal (Google, 2014). Users and crawlers should access only the HTTPS version.

Requirement Action
SSL/TLS certificate Install valid certificate; use Let's Encrypt for free
301 redirect HTTP → HTTPS; all HTTP requests redirect to HTTPS
Mixed content No HTTP resources on HTTPS pages; fix mixed content warnings
HSTS Optional; Strict-Transport-Security header for repeat visitors

WWW vs non-WWW: Choose one preferred version; 301 redirect the other. See canonical rules above.

When to Use Canonical

  • Multi-language: Each language version has its own canonical; use hreflang with canonical
  • Same content, multiple URLs: Params, pagination, tracking params, www vs non-www, trailing slash (/page vs /page/)
  • Self-referencing: Canonical should point to self or the preferred version
  • Avoid chain canonical: A→B→C is invalid

Rules

Rule Note
Absolute URL Include https://
Consistency Must match current page URL or the chosen preferred version
No chains A→B→C is invalid

Implementation Patterns

Next.js (metadata)
export const metadata = {
  alternates: {
    canonical: "https://example.com/page-slug",
    languages: {
      zh: "https://example.com/zh/page-slug",
      en: "https://example.com/page-slug",
      "x-default": "https://example.com/page-slug",
    },
  },
};
HTML (generic)
<link rel="canonical" href="https://example.com/page-slug" />
Server Redirects (301)

Apache (.htaccess):

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Nginx:

return 301 https://$host$request_uri;

Relationship to Other Technical SEO

  • Sitemap: URLs in sitemap should match canonical
  • IndexNow: Submit canonical URLs

Output Format

  • url-structure: URL hierarchy and format; canonical handles duplicate variants (HTTPS, www, trailing slash)
  • localization-strategy: hreflang + canonical for multi-language
  • xml-sitemap: Sitemap URLs should match canonical
  • indexnow: Submit canonical URLs
  • google-search-console: Find duplicate content in Coverage report
  • indexing: Resolve indexing issues
  • site-crawlability: Crawl budget; redirect chains; canonical reduces duplicate crawl waste
1---
2name: canonical-tag
3description: When the user wants to configure canonical URLs, fix duplicate content, or consolidate URL signals. Also use when the user mentions "canonical," "canonical URL," "duplicate content," "duplicate content fix," "preferred URL," or "URL consolidation." For GSC duplicates, use google-search-console.
4metadata:
5 version: 1.0.1
6---
7 
8# SEO Technical: Canonical
9 
10Guides canonical tag configuration to consolidate duplicate content and declare preferred URLs.
11 
12**When invoking**: On **first use**, if helpful, open with 1–2 sentences on what this skill covers and why it matters, then provide the main output. On **subsequent use** or when the user asks to skip, go directly to the main output.
13 
14## Scope (Technical SEO)
15 
16- **Duplicate site versions**: HTTPS vs HTTP; www vs non-www; trailing slash (/page vs /page/) — choose one, 301 redirect others
17- **Duplicate content**: Canonical tags; consolidate and 301 to preferred URL
18- **HTTPS**: SSL/TLS; secure connection; ranking signal since 2014
19 
20## Initial Assessment
21 
22**Project context:** Read root `contextus.md` when present and load only the modules relevant to this task. Without Contextus, use available project material or user-provided facts and ask for missing information; do not create a parallel context system.
23 
24Identify:
251. **Site URL**: Base domain
262. **Duplicate scenarios**: Multi-language, query params, pagination, alternate URLs
273. **Framework**: Next.js, React, static, etc.
28 
29## Canonicalization Methods (Choose by Scenario)
30 
31| Method | When | Strength |
32|--------|------|----------|
33| **301 redirect** | Preferred; server can redirect | Strongest — permanent redirect |
34| **Canonical tag** | Cannot redirect (e.g. params, pagination) | Strong — HTML signal |
35| **robots.txt** | Block non-canonical paths | Weak — advisory only |
36 
37Use 301 for HTTP→HTTPS, www variants, trailing slash. Use canonical for params, pagination, UTM.
38 
39## HTTPS & Security
40 
41HTTPS is a ranking signal ([Google, 2014](https://developers.google.com/search/blog/2014/08/https-as-ranking-signal)). Users and crawlers should access only the HTTPS version.
42 
43| Requirement | Action |
44|-------------|--------|
45| **SSL/TLS certificate** | Install valid certificate; use Let's Encrypt for free |
46| **301 redirect** | HTTP → HTTPS; all HTTP requests redirect to HTTPS |
47| **Mixed content** | No HTTP resources on HTTPS pages; fix mixed content warnings |
48| **HSTS** | Optional; `Strict-Transport-Security` header for repeat visitors |
49 
50**WWW vs non-WWW**: Choose one preferred version; 301 redirect the other. See canonical rules above.
51 
52## When to Use Canonical
53 
54- **Multi-language**: Each language version has its own canonical; use **hreflang** with canonical
55- **Same content, multiple URLs**: Params, pagination, tracking params, www vs non-www, trailing slash (/page vs /page/)
56- **Self-referencing**: Canonical should point to self or the preferred version
57- **Avoid chain canonical**: A→B→C is invalid
58 
59## Rules
60 
61| Rule | Note |
62|------|------|
63| **Absolute URL** | Include `https://` |
64| **Consistency** | Must match current page URL or the chosen preferred version |
65| **No chains** | A→B→C is invalid |
66 
67## Implementation Patterns
68 
69### Next.js (metadata)
70 
71```tsx
72export const metadata = {
73 alternates: {
74 canonical: "https://example.com/page-slug",
75 languages: {
76 zh: "https://example.com/zh/page-slug",
77 en: "https://example.com/page-slug",
78 "x-default": "https://example.com/page-slug",
79 },
80 },
81};
82```
83 
84### HTML (generic)
85 
86```html
87<link rel="canonical" href="https://example.com/page-slug" />
88```
89 
90### Server Redirects (301)
91 
92**Apache (.htaccess)**:
93```apache
94RewriteEngine On
95RewriteCond %{HTTPS} off
96RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
97```
98 
99**Nginx**:
100```nginx
101return 301 https://$host$request_uri;
102```
103 
104## Relationship to Other Technical SEO
105 
106- **Sitemap**: URLs in sitemap should match canonical
107- **IndexNow**: Submit canonical URLs
108 
109## Output Format
110 
111- **Canonical URL** for each page type
112- **Implementation** (metadata or HTML)
113- **Multi-language** setup if applicable
114- **References**: [Alignify URL optimization](https://alignify.co/zh/seo/url-optimization); [Google Canonical](https://developers.google.com/search/docs/crawling-indexing/consolidate-duplicate-urls)
115 
116## Related Skills
117 
118- **url-structure**: URL hierarchy and format; canonical handles duplicate variants (HTTPS, www, trailing slash)
119- **localization-strategy**: hreflang + canonical for multi-language
120- **xml-sitemap**: Sitemap URLs should match canonical
121- **indexnow**: Submit canonical URLs
122- **google-search-console**: Find duplicate content in Coverage report
123- **indexing**: Resolve indexing issues
124- **site-crawlability**: Crawl budget; redirect chains; canonical reduces duplicate crawl waste
125 

Discussion

Alternatives

Agentic Browsing ReadinessAudit and fix agent readiness: the Lighthouse Agentic Browsing fraction, accessibility tree for agents, robots.txt and Content-Signal for AI agents, WAF treatment of agent traffic, llms.txt, Markdown delivery, ai-catalog.json, /.well-known discovery files, and WebMCP tools. Exclude AI citability and brand signals (seo-geo) and commerce protocol depth (seo-ecommerce).Marketing · MITBacklink Profile AnalysisBacklink profile analysis: referring domains, anchor text distribution, toxic link detection, competitor gap analysis. Works with free APIs (Moz, Bing Webmaster, Common Crawl) and DataForSEO extension. Use when user says backlinks, link profile, referring domains, anchor text, toxic links, link gap, link building, disavow, or backlink audit.Marketing · MIT/setup-cmsConnect a CMS to notfair SEO tools. Guides users through configuring WordPress, Strapi, Contentful, or Ghost — tests the connection, and writes credentials to .env.local. Once set up, seo-analysis automatically cross- references CMS content against Google Search Console data. Use whenever the user says "connect my CMS", "set up WordPress", "configure Strapi", "add Contentful", "connect Ghost", or "CMS setup". Also trigger if the user asks why no CMS data appears in a seo-analysis report. · MITBacklink checkBacklink profile for any domain — referring domains, authority, anchors, new/lost links, and a side-by-side vs a competitor. Use when asked "check my backlinks", "backlink profile of X", "who links to them", or "link gap vs competitor".Marketing · MIT