```yaml
product: AlterLab
title: "Canonical URL — Web Scraping Glossary | AlterLab"
comparison_context: "AlterLab is an alternative to Firecrawl, ScrapingBee, and Bright Data."
source_url: https://alterlab.io/glossary/canonical-url
```

general

# Canonical URL

A canonical URL is the preferred URL for a piece of content when multiple URLs serve the same or similar content, indicated by a `<link rel='canonical'>` tag.

When the same content is accessible at multiple URLs — due to query parameters, trailing slashes, `www` vs. non-`www` subdomains, or session tokens — search engines and scrapers need to know which URL to treat as authoritative. The `rel=canonical` link tag in the HTML `<head>` signals the preferred URL.

For crawlers, following canonical URLs prevents indexing duplicate content and wasting crawl budget. A robust crawler reads the canonical tag and records the canonical URL alongside or instead of the requested URL. Deduplication logic can then match records by canonical URL rather than the exact URL that was fetched.

Canonical URLs also matter for link graph construction: inbound links to duplicate URLs should be consolidated and attributed to the canonical for accurate page-authority calculations.

### What is Canonical URL?

A canonical URL is the preferred URL for a piece of content when multiple URLs serve the same or similar content, indicated by a `<link rel='canonical'>` tag.

### How does AlterLab handle Canonical URL?

Canonical URLs also matter for link graph construction: inbound links to duplicate URLs should be consolidated and attributed to the canonical for accurate page-authority calculations.

## Examples

```
<!-- Canonical tag in page <head> -->
<link rel="canonical" href="https://example.com/products/widget" />

<!-- Scraper extraction -->
from bs4 import BeautifulSoup
canonical = soup.find("link", rel="canonical")
canonical_url = canonical["href"] if canonical else response.url
```

## Related Terms

[URLA URL (Uniform Resource Locator) is the address of a resource on the web, comprising a scheme, host, optional port, path, query string, and fragment.](https://alterlab.io/glossary/url)[SitemapAn XML file listing all URLs on a website with metadata like last modification date, helping crawlers discover and prioritise pages.](https://alterlab.io/glossary/sitemap)[robots.txtA plain-text file at a website's root specifying which URL paths crawlers are permitted or disallowed from accessing.](https://alterlab.io/glossary/robots-txt)[PaginationThe division of large data sets across multiple pages, requiring scrapers to follow next-page links or increment page parameters to retrieve complete data.](https://alterlab.io/glossary/pagination)[Link FollowingLink following (or crawling) is the process of discovering and visiting URLs by extracting hyperlinks from already-scraped pages, enabling systematic traversal of a website.](https://alterlab.io/glossary/link-following)

## Extract Canonical URL data from any website

AlterLab returns clean, structured data from any public URL — no scraper infrastructure needed. Start free, no credit card required.

[View API docs](https://alterlab.io/docs/api/rest)

[Back to Glossary](https://alterlab.io/glossary)