canonical-tag by kostja94/marketing-skills
npx skills add https://github.com/kostja94/marketing-skills --skill canonical-tag指导 canonical 标签配置,以整合重复内容并声明首选 URL。
调用时机:在首次使用时,如果适用,请以 1-2 句话开头,说明此技能涵盖的内容及其重要性,然后提供主要输出。在后续使用或用户要求跳过时,直接进入主要输出。
首先检查项目上下文:如果存在 .claude/project-context.md 或 .cursor/project-context.md,请阅读以获取网站 URL 和语言结构。
识别:
| 方法 | 适用场景 |
|---|
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 强度 |
|---|
| 301 重定向 | 首选;服务器可以重定向 | 最强——永久重定向 |
| Canonical 标签 | 无法重定向时(例如参数、分页) | 强——HTML 信号 |
| robots.txt | 阻止非规范路径 | 弱——仅建议性 |
对 HTTP→HTTPS、www 变体、尾部斜杠使用 301 重定向。对参数、分页、UTM 参数使用 canonical。
HTTPS 是一个排名信号(Google, 2014)。用户和爬虫应仅访问 HTTPS 版本。
| 要求 | 操作 |
|---|---|
| SSL/TLS 证书 | 安装有效证书;可使用 Let's Encrypt 免费获取 |
| 301 重定向 | HTTP → HTTPS;所有 HTTP 请求重定向到 HTTPS |
| 混合内容 | HTTPS 页面上不应有 HTTP 资源;修复混合内容警告 |
| HSTS | 可选;为重复访问者设置 Strict-Transport-Security 响应头 |
WWW 与非 WWW:选择一个首选版本;对另一个进行 301 重定向。参见上述规范化规则。
| 规则 | 说明 |
|---|---|
| 绝对 URL | 包含 https:// |
| 一致性 | 必须与当前页面 URL 或选定的首选版本匹配 |
| 无链式 | A→B→C 是无效的 |
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",
},
},
};
<link rel="canonical" href="https://example.com/page-slug" />
Apache (.htaccess) :
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Nginx :
return 301 https://$host$request_uri;
每周安装量
198
代码仓库
GitHub 星标数
237
首次出现
2026年3月1日
安全审计
安装于
kimi-cli182
cursor182
gemini-cli181
codex181
github-copilot181
opencode181
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.
Check for project context first: If .claude/project-context.md or .cursor/project-context.md exists, read it for site URL and language structure.
Identify:
| 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 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.
| Rule | Note |
|---|---|
| Absolute URL | Include https:// |
| Consistency | Must match current page URL or the chosen preferred version |
| No chains | A→B→C is invalid |
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",
},
},
};
<link rel="canonical" href="https://example.com/page-slug" />
Apache (.htaccess) :
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Nginx :
return 301 https://$host$request_uri;
Weekly Installs
198
Repository
GitHub Stars
237
First Seen
Mar 1, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
kimi-cli182
cursor182
gemini-cli181
codex181
github-copilot181
opencode181
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
111,800 周安装