In short. Do not use a fragment identifier in a canonical target for Google Search.
Definition: A canonical URL is the URL a site indicates as the preferred representative among duplicate or very similar pages. Google Search documentation says that a URL containing a fragment identifier should not be specified as that canonical target because Google generally does not support URL fragments.
Key facts
- Google's canonicalization documentation calls
rel="canonical"a strong signal for the URL that should become canonical. - The same documentation says, “Don't specify a URL fragment as canonical,” because Google generally does not support URL fragments.
- Google's URL structure documentation says fragments should not change page content and gives
https://example.com/#/potatoesas an example. - RFC 3986 defines a fragment identifier as an indirect reference to a secondary resource associated with a primary resource.
- The RFC says a fragment is separated from the rest of a URI before dereferencing, with the identifying information handled by the user agent.
Why is a fragment a poor canonical target?
A canonical declaration identifies the representative page for duplicate or very similar pages. Google lists redirects, rel="canonical" link annotations and sitemap inclusion as ways to indicate that preference. It describes rel="canonical" annotations as a strong signal that the specified URL should become canonical.
A fragment identifier has a different role in URI syntax. RFC 3986 says it can identify a portion, subset or view of a primary resource. Its meaning depends on the representation's media type, so a fragment can identify a view within a document without identifying a separate page that a search system should treat as the canonical representative.
Google's rule follows that distinction: a fragment-bearing URL is unsuitable for a canonical declaration in Google Search. The guidance is about the canonical target, so a page can still contain ordinary same-page links that use fragments for navigation.
What should the canonical element contain?
Put the canonical link element in the HTML head of duplicate pages and point it to the page URL without a fragment. Google's example is:
<html>
<head>
<title>Explore the world of dresses</title>
<link rel="canonical" href="https://example.com/dresses/green-dresses" />
<!-- other elements -->
</head>
<!-- rest of the HTML -->
The same documentation describes the element as indicating that another page is representative of the content on the page. It also recommends adding the same self-referential element to the canonical page itself. Use an absolute URL in the href; Google says relative paths are supported but recommends absolute paths because relative paths can cause problems over time.
If a site uses client-side rendering, Google advises keeping the canonical information clear in the HTML source and ensuring that JavaScript does not change the canonical link element. If the canonical URL cannot be set in the HTML source, Google says to leave it out and set it only with JavaScript.
What should a fragment do on a page?
Use a fragment for a location or view inside a document when the browser and the document format give it that meaning. RFC 3986 describes the fragment as information that is separated before a URI is dereferenced and handled by the user agent. That makes it a page-location mechanism rather than a substitute for a distinct canonical page URL.
Google separately advises against using fragments to change page content because Google Search generally does not support URL fragments. For JavaScript-driven content changes, its URL guidance points to the History API. A content variant that needs its own canonical identity therefore needs its own URL path or query design, followed by a canonical declaration that omits the fragment.
Related terms
FAQ
Can a rel="canonical" value end with #section?
Google's canonicalization guidance says not to specify a URL fragment as canonical. Use the page URL without the fragment as the canonical target.
Can a fragment identify a section for visitors?
Yes. RFC 3986 defines a fragment as a reference to a secondary resource such as a portion, subset or view of a primary resource. Google’s restriction concerns canonical declarations and fragment-driven content changes.
What should a JavaScript site use when content changes?
Google's URL guidance recommends the History API when JavaScript changes content. The canonical URL should remain an absolute page URL without a fragment.
Sources
- Google Search Central, "How to specify a canonical URL with rel="canonical" and other methods", 10 July 2026
- Google Search Central, "URL structure", 10 December 2025
- IETF, "RFC 3986: Uniform Resource Identifier (URI): Generic Syntax", January 2005
Check how a page reads to answer engines. Open the GEO score analyzer