URL: /rules/core/canonical-header

---
title: "Canonical Header Validation"
description: "Detects mismatch between HTML canonical tag and Link header"
---

Detects mismatch between HTML canonical tag and Link header

| | |
|---|---|
| **Rule ID** | `core/canonical-header` |
| **Category** | [Core SEO](/rules/core) |
| **Scope** | Per-page |
| **Severity** | warning |
| **Weight** | 7/10 |

## Solution

When both HTML canonical tag and HTTP Link header are present, they must match. Search engines may get confused by conflicting signals.

HTML: `<link rel="canonical" href="https://example.com/page">`
HTTP: `Link: <https://example.com/page>; rel="canonical"`

Best practice: Use HTML canonical tag only. Only add Link header if unable to modify HTML (e.g., PDF files).

## Enable / Disable

### Disable this rule

```toml squirrel.toml
[rules]
disable = ["core/canonical-header"]
```

### Disable all Core SEO rules

```toml squirrel.toml
[rules]
disable = ["core/*"]
```

### Enable only this rule

```toml squirrel.toml
[rules]
enable = ["core/canonical-header"]
disable = ["*"]
```
