A canonical tag generator turns one absolute HTTP or HTTPS URL into a clean, HTML-escaped rel=canonical link element ready to paste into a page head. The tool accepts only public, credential-free addresses, drops any fragment, normalizes the host and default port through the browser URL parser and escapes ampersands in the resulting href so the attribute is valid markup. The path case and any intentional query string are preserved because the generator never guesses which tracking parameters, sort keys or trailing-slash policy your site uses. The output is markup only, not a guarantee: search systems combine canonical annotations with redirects, sitemaps, internal links and content evidence when deciding which URL to index. Use the generator to produce a consistent link element, then place it inside the HTML head of every duplicate version, point it at the same preferred 200 page and confirm the delivered document shows one canonical signal across templates, headers and sitemap entries.

What the Generator Accepts as Input
The tool restricts input to credential-free absolute HTTP and HTTPS addresses. Paste a complete URL, including the scheme and host, followed by the path and any query string that is part of the deliberate canonical target. The host part can be a regular ASCII name or an internationalized domain; the browser will serialize it. Anything that is not a complete HTTP or HTTPS URL is rejected before normalization runs.
- Relative paths such as /products/widget are rejected because their meaning shifts with the document location and deployment environment.
- Non-HTTP schemes such as ftp, javascript, data or mailto are not valid canonical targets in this generator.
- URLs that embed a username or password, like https://user:[email protected]/page, are rejected because a canonical should identify public content, not expose credentials in markup.
- If the page requires authentication, canonicalization does not make it public and does not solve access control, so the indexing question is a separate decision.
This narrow acceptance window is what allows the generator to return a deterministic, reviewable element. Add an explicit intent to the input and the resulting tag will always point to the same public address across runs.
Normalization Rules at a Glance
The browser URL parser does the heavy lifting on every accepted input. The rules below describe exactly what changes and what stays, so the displayed normalized URL matches the form you would type in a browser address bar and the href stays valid HTML.
- Host case is folded to lowercase. Example.com becomes example.com.
- Default ports are removed. Port 80 disappears from http URLs, and port 443 disappears from https URLs.
- Internationalized domains are converted to their ASCII-compatible form for storage in the href.
- Path case is preserved. /Products/Widget stays as written because URLs are case-sensitive in the path segment.
- Query strings are preserved in full, including order and any tracking parameters you typed.
- Fragments are removed entirely. https://example.com/page#details produces a target of https://example.com/page because a fragment points into a representation rather than a separate network resource.
- Ampersands in the href are HTML-escaped as & so the attribute parses cleanly, while the displayed normalized URL still shows the ordinary & character.
A short worked transformation: enter https://Example.com:443/Page?ref=home#top. The normalized address shown for review is https://example.com/Page?ref=home. The pasted markup is <link rel="canonical" href="https://example.com/Page?ref=home">, with the ampersand in the href appearing as & in source so the attribute stays valid.
Generate a Canonical Tag in Three Steps
- Enter the complete preferred HTTP or HTTPS URL into the Canonical Tag Generator, including scheme, host, path and any intentional query string.
- Generate the tag and read back the normalized address; compare it character-by-character against the real 200 page you want search engines to prefer, paying attention to host case, default ports, IDN form, path case and preserved query parameters.
- Copy the element into the HTML head of the canonical target, then inspect the delivered page source and confirm one canonical element exists with an href that resolves to a live, equivalent page.
Step two is where most mistakes get caught. If the normalized address has lost an intended query string, the input was wrong. If the path is unexpectedly lowercased, that is the live URL your server returns and the canonical should match it. If a fragment disappeared, the tool removed it deliberately and the underlying resource URL is the correct target.
Input-to-Output Field Reference
The table below summarizes what the generator does to common input shapes. Use it as a quick lookup when you are reviewing a generated tag before pasting it.
| Input shape | Normalized href | Action |
|---|---|---|
| https://example.com/ | https://example.com/ | Root path kept, slash retained |
| HTTPS://Example.com:443/Page | https://example.com/Page | Host case folded, default HTTPS port removed |
| http://example.com:80/Page | http://example.com/Page | Default HTTP port removed |
| https://例え.com/page | https://xn--r8jz45c.com/page | Internationalized domain converted to ASCII |
| https://example.com/page?a=1&b=2 | https://example.com/page?a=1&b=2 in href | Query preserved, ampersand escaped in markup |
| https://example.com/page#details | https://example.com/page | Fragment removed |
| /products/widget | — | Rejected: relative path |
| https://user:[email protected]/page | — | Rejected: embedded credentials |
| ftp://example.com/file | — | Rejected: scheme not HTTP(S) |
The escaped ampersand row is the one that surprises new users. The visible normalized URL keeps & while the markup keeps &. Both refer to the same network address, but only the second form is valid inside an HTML attribute, and the parsing rules that govern attribute decoding are described in the WHATWG URL Standard.
Where to Place the Generated Element
The generated link element belongs inside the HTML head of the page, not in the body. Browsers and crawlers expect head metadata at the top of the document, and most frameworks that look for a canonical signal scan only the head. A canonical in the body may be ignored entirely, depending on how the crawler parses the document.
For client-rendered applications, make sure the canonical is present in the source output the server sends, not only after a script runs. If a script appends or rewrites the canonical after load, different crawlers may see different href values, which dilutes the signal. Run a quick fetch of the rendered URL, or view source, and confirm the href is the one you pasted.
The generator returns one element at a time. If a CMS already inserts its own canonical, do not stack a second one on top of it; pick the one your platform owns and remove the other. Stacked canonicals create an inconsistent signal that search systems have to resolve on their own, which is the opposite of what a canonical annotation is for.
Signals to Keep Consistent Across Pages
A canonical tag is one signal among several, and it works best when other signals agree with it. Before you treat a duplicate cluster as resolved, check the following against the same preferred URL.
- HTML head canonical: one element, href matches the preferred address.
- HTTP header canonical: if the server emits an X-Robots-Tag or Link rel=canonical header, the target should match the HTML head href.
- Sitemap: the URL listed in the XML sitemap should be the preferred one, not a duplicate.
- Internal links: representative internal links should point at the preferred address rather than the duplicates.
- Redirects: retired duplicates should 301 to the preferred address, not merely carry a canonical that points to it.
If any of these disagree, the canonical annotation still helps, but you have handed the search system a small puzzle instead of a clean answer. For the broader mechanics of how search systems consolidate duplicates, the Google Search Central documentation on canonical URLs is the standard reference.
What the Tool Does Not Do
The generator is deliberately narrow. It does not strip tracking parameters, sort query keys, force HTTPS, add or remove www, choose a trailing-slash policy, resolve redirects or inspect page similarity. Each of those decisions depends on your site's routing and content, and the tool cannot infer them safely. A valid-looking tag that points to the wrong page is worse than no tag at all, because the search system has to spend effort discounting it.
If your site has both an http and an https version, an www and a non-www version, or a trailing-slash and a no-trailing-slash version, resolve those choices at the redirect and sitemap layer first. Then run the surviving preferred address through the Canonical Tag Generator so the annotation matches the version that actually serves content, and confirm the resulting href is what your live 200 page returns.