What the generator changes in the URL you enter
The canonical tag generator takes the URL you want indexed and normalizes it before writing any code. Everything happens in your browser; the URL is not sent anywhere. Each adjustment addresses a common way two addresses for one page drift apart:
- Lowercase host.
WWW.Example.comandwww.example.comreach the same server, so the generator writes the host in lowercase. - HTTPS. Google favors the HTTPS version as canonical unless that version is broken, so the output uses https.
- Trailing slash, optionally.
/pageand/page/are different URLs. The option exists because only you know which form your server answers with a 200 and which it redirects. - Tracking parameters removed.
utm_values and similar tags describe how a visitor arrived, not what the page is, so they never belong in a canonical.
What the generator cannot know matters as much. It does not check that the normalized URL exists, returns 200, or matches whether your site uses the www or bare host. It removes tracking parameters but cannot judge a parameter that changes content, such as a color or size filter; whether that variant should consolidate is your decision.
Three output formats and where each belongs
| Output | Use it for | Watch for |
|---|---|---|
HTML <link> element | Ordinary HTML pages | Must sit in the head |
HTTP Link header | PDFs and other files with no head | Invisible in source; must agree with any HTML tag |
| PHP example | Templates that assemble the head or send headers in code | Must not overwrite other Link headers |
For an HTML page, the link element is the better default. It is visible in source, to crawlers and to anyone debugging the page. The header form is what Google documents for non-HTML files, and Google says it supports that method for web search results only.
<link rel="canonical" href="https://www.example.com/page">
Link: <https://www.example.com/page>; rel="canonical"
If you send the header from PHP, note the second argument of header(). By default a new header replaces an earlier one of the same type; passing false lets it sit beside existing Link headers, such as those a CMS sends for its API.
Placing the tag so it is read
- In the head, early. Google stops reading the head at the first element that does not belong there, such as an
imgoriframe. A canonical after one may be missed even though View Source shows it inside the head. - Once. A theme and an SEO plugin that each print a canonical produce two tags, and multiple canonicals tend to be ignored together. Check the page after adding yours.
- One method, or methods that agree. Google's documentation says not to name different canonicals through different techniques. Do not add the header to a page whose HTML already declares a different URL.
- No extra attributes. Google says canonical annotations carrying
hreflang,lang,mediaortypeare not used for canonicalization. Language alternates go in separaterel="alternate"links. - Per page, not per template. Each paginated page and each distinct page needs its own value. A canonical pasted once into a shared header points every page at the same URL.
Choosing the URL to generate
Correct syntax around the wrong URL is still a problem. RFC 6596, which defines the canonical link relation, describes the target as a page whose content duplicates or is a superset of the page carrying the tag. It should not be the source of a permanent redirect or a URL that returns an error. In practice, the target should return 200 directly, carry its own self-referencing canonical, have no noindex and not be blocked in robots.txt.
Sometimes the canonical is the wrong tool entirely:
- If the duplicate URL should disappear, a 301 redirect is the more reliable way to consolidate.
- If a page should stay out of the index, that is noindex, used on its own rather than alongside a cross-page canonical.
- For content republished by syndication partners, Google no longer recommends cross-domain canonicals and suggests the partner keep its copy out of the index instead.
A self-referencing canonical on the preferred page is recommended by Google but not required. It earns its place on pages that pick up parameters or alternate paths.
After the tag is live
Generated code is only a draft until the deployed page confirms it. Fetch the page with the canonical tag checker to see that exactly one canonical appears, in the head or the header as intended, and that it matches the output here. Then give Google time to recrawl and compare the user-declared and Google-selected canonicals in Search Console's URL Inspection. A canonical is a hint; if Google still chooses another URL, look at the signals that disagree with it, usually redirects, internal links and sitemap entries.
Frequently asked questions
Does the canonical tag generator send my URL to a server?
No. Normalization and code generation run in your browser. Nothing is fetched, which is also why the generator cannot confirm that the resulting URL exists or returns 200.
Should my canonical URL end with a trailing slash?
It should match the version your server returns with a 200 status and the version your internal links and sitemap use. Either convention works if it is applied consistently and the other form redirects to it. A canonical that names the redirected form points the hint at a redirect.
Why does the generator remove utm parameters?
Tracking parameters record where a visit came from and do not change the content. A canonical that keeps them names a campaign URL as the preferred version. Stripping them lets every tagged link consolidate onto the clean URL.
Should I use the HTML tag or the HTTP header?
Use the HTML link element for HTML pages, and the HTTP Link header for PDFs and other files that have no head. If a page must use the header, remove any HTML canonical rather than run both, since Google publishes no rule for which wins when they disagree.
Will adding the generated tag make Google index that URL?
Not necessarily. Google treats rel=canonical as a strong hint and weighs it with redirects, HTTPS, sitemaps and internal links. When those signals point to the same URL, agreement is much more likely.
Can I use the generator for a canonical that points to another domain?
The syntax is the same, and a cross-domain canonical is supported as a hint. For content republished by syndication partners, Google no longer recommends it and suggests the partner keep its copy out of the index instead. Cross-domain canonicals fit best when you own both sites and the pages are genuinely the same.