# Canonical Consistency Audit (`zerobreak/canonical-consistency-audit`) Actor

A canonical consistency audit tool that crawls any list of URLs, inspects canonical tags, and flags missing, duplicate, or mismatched canonicals so SEO teams can fix indexation issues before they damage rankings.

- **URL**: https://apify.com/zerobreak/canonical-consistency-audit.md
- **Developed by:** [ZeroBreak](https://apify.com/zerobreak) (community)
- **Categories:** Developer tools, SEO tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.99 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Canonical Consistency Audit — Find & Fix Canonical Tag Issues on Any Website

Canonical consistency audit tool that checks every URL for correct canonical tag configuration so search engines always index the right page. Feed it any list of URLs and get instant, structured insight into canonical health across your entire site.

### Use Cases

- **SEO auditing** — Bulk-check hundreds of pages before a site launch to ensure every URL has a valid, self-referencing canonical tag
- **Indexation troubleshooting** — Identify pages where canonicals point elsewhere, causing the wrong version to rank
- **Duplicate content detection** — Surface pages with missing or conflicting canonical tags that split link equity
- **Redirect chain validation** — Catch redirect hops that silently break canonical intent
- **QA for migrations** — Verify canonical consistency after domain migrations or platform changes
- **Ongoing SEO monitoring** — Schedule regular audits to detect canonical regressions before they affect rankings

### Input

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `url` | string | — | Single URL to audit |
| `urls` | array | — | List of URLs to audit. Merged with `url` if both provided |
| `maxConcurrency` | integer | `5` | Number of URLs audited in parallel (1–50) |

#### Example Input

```json
{
    "urls": [
        "https://example.com/",
        "https://example.com/blog/seo-tips",
        "https://example.com/products/widget-pro"
    ],
    "maxConcurrency": 10
}
```

### What Data Does This Actor Extract?

The actor stores one result per URL in a dataset. Each entry contains:

```json
{
    "inputUrl": "https://example.com/blog/seo-tips",
    "finalUrl": "https://example.com/blog/seo-tips",
    "statusCode": 200,
    "hasCanonical": true,
    "canonicalCount": 1,
    "canonicalUrl": "https://example.com/blog/seo-tips",
    "isSelfCanonical": true,
    "isHealthy": true,
    "issues": [],
    "auditedAt": "2025-06-01T10:23:45.123456+00:00"
}
```

| Field | Type | Description |
|-------|------|-------------|
| `inputUrl` | string | The original URL submitted for auditing |
| `finalUrl` | string | The final URL after following redirects |
| `statusCode` | integer | HTTP response status code |
| `hasCanonical` | boolean | Whether the page has at least one canonical tag |
| `canonicalCount` | integer | Total canonical tags found (healthy = 1) |
| `canonicalUrl` | string | Canonical URL declared on the page (absolute) |
| `isSelfCanonical` | boolean | Whether the canonical points back to this page |
| `isHealthy` | boolean | True when exactly one self-referencing canonical is found and no issues detected |
| `issues` | array | Human-readable list of issues found on this page |
| `auditedAt` | string | ISO 8601 timestamp of the audit |

### How It Works

1. Accepts one or more URLs via `url` / `urls` input fields
2. Deduplicates and normalizes all URLs (adds `https://` if scheme is missing)
3. Fetches each page concurrently using async HTTP (bounded by `maxConcurrency`)
4. Parses the HTML response and locates all `<link rel="canonical">` elements
5. Resolves relative canonical hrefs to absolute URLs
6. Checks for issues: missing canonical, multiple canonicals, non-self canonical, empty href
7. Flags redirect chains where the final URL differs from the input
8. Pushes a structured result for every URL to the Apify dataset

### FAQ

**What counts as a healthy canonical?**
A page is healthy when it has exactly one `<link rel="canonical">` tag whose `href` resolves to the same URL as the page itself (after normalizing trailing slashes and scheme).

**Does the actor follow redirects?**
Yes. It follows redirect chains and records the final URL. If the final URL differs from the input, an issue is logged so you can identify unintentional redirect hops that may break canonical intent.

**Can it handle relative canonical URLs?**
Yes. Relative hrefs like `/page` or `../other` are resolved against the final URL before comparison.

**How many URLs can I audit in one run?**
There is no hard limit. Use `maxConcurrency` to tune throughput vs. server load. For very large lists (10,000+) consider splitting into batches.

**Why does my page show `isSelfCanonical: false`?**
The canonical href on that page points to a different URL — typically a preferred version (with/without trailing slash, www vs non-www, or a completely different URL). Review the `canonicalUrl` field to see where it points.

### Integrations

Connect Canonical Consistency Audit with other apps and services using [Apify integrations](https://apify.com/integrations). You can integrate with Make, Zapier, Slack, Airbyte, GitHub, Google Sheets, Google Drive, and many more. You can also use [webhooks](https://docs.apify.com/integrations/webhooks) to trigger actions whenever results are available.

Start your canonical consistency audit today and ensure every page on your site is signalling the right URL to search engines.

# Actor input Schema

## `url` (type: `string`):

Single URL to audit for canonical tag consistency.

## `urls` (type: `array`):

List of URLs to audit. Merged with the single 'url' field if both are provided.

## `maxConcurrency` (type: `integer`):

Number of URLs to audit concurrently. Higher values are faster but may trigger rate limits.

## Actor input object example

```json
{
  "url": "https://example.com/page",
  "urls": [
    "https://example.com/page-1",
    "https://example.com/page-2"
  ],
  "maxConcurrency": 5
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "url": "https://example.com/"
};

// Run the Actor and wait for it to finish
const run = await client.actor("zerobreak/canonical-consistency-audit").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "url": "https://example.com/" }

# Run the Actor and wait for it to finish
run = client.actor("zerobreak/canonical-consistency-audit").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "url": "https://example.com/"
}' |
apify call zerobreak/canonical-consistency-audit --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,zerobreak/canonical-consistency-audit"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/bqiEaeOau5OANw7pk/builds/gVPmeTk3sscCD84tX/openapi.json
