# URL fragment

> A URL fragment is the part after #. It is handled by the browser, not sent to the server. What that means for canonicals, JavaScript routing, and crawlable links.

Canonical: https://scaplet.com/glossary/url-fragment

Glossary Glossary · Crawling and indexing

A URL fragment is the part after #. It is handled by the browser, not sent to the server. What that means for canonicals, JavaScript routing, and crawlable links.

2 min

read

4

sources

Oct 29, 2026

updated

Scaplet Editorial Team

author

In one line

A URL fragment is the final part of a URL, starting with #. It points to a spot inside a resource, such as a heading or a video timestamp, and is handled by the browser after the page loads, not sent in the request. Google advises against loading different content by fragment and against using one as a canonical URL.

30-second check

## Is this costing your site traffic?

Four quick questions, then a straight answer.

1/4Have you checked your own site for this?

Summarize this page with [ChatGPT](https://chatgpt.com/?hints=search&q=Summarize%20https%3A%2F%2Fscaplet.com%2Fglossary%2Furl-fragment%20(%22URL%20fragment%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Claude](https://claude.ai/new?q=Summarize%20https%3A%2F%2Fscaplet.com%2Fglossary%2Furl-fragment%20(%22URL%20fragment%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [Perplexity](https://www.perplexity.ai/search?q=Summarize%20https%3A%2F%2Fscaplet.com%2Fglossary%2Furl-fragment%20(%22URL%20fragment%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.) [![Google](/logos/ai/google-color.svg)AI Mode](https://www.google.com/search?udm=50&q=Summarize%20https%3A%2F%2Fscaplet.com%2Fglossary%2Furl-fragment%20(%22URL%20fragment%22)%20in%205%20bullet%20points%2C%20then%20tell%20me%20the%20one%20thing%20I%20should%20do%20next.)

## At a glance

4 facts from the sources below

#

Starts with

No, handled by the browser

Sent to server

Generally not supported

Google as canonical

History API, not fragments

SPA routing advice

_01_At a glance

## Anatomy of a URL with a fragment

Form

### `#setup`

What the browser does

Scrolls to the element with `id="setup"`

Form

### `#t=10,20` (media fragment)

What the browser does

On audio or video, starts playback at the given time

Form

### `#:~:text=fragment`

What the browser does

Text fragment: highlights matching text on the page

Where the fragment sits

```
https://www.example.com/path/guide?lang=en#setup scheme host path query fragment
```

MDN says the fragment is handled entirely by the client and isn't included in the request, and RFC 3986 describes it being split off before the URI is dereferenced. The server never sees it, so two URLs that differ only after the `#` fetch the same response.

_02_Worth knowing

## Three places fragments cause SEO trouble

### Content swapped by fragment

Google's [JavaScript SEO](/glossary/javascript-seo) guide warns against loading different content based on the fragment, because [Googlebot](/ai-crawlers/googlebot) can't reliably resolve those URLs. Its section is titled "Use the History API instead of fragments."

### Fragment as canonical

Google's consolidation guide says not to specify a fragment as the [canonical URL](/glossary/canonical-url), because Google generally doesn't support fragments.

### Non-link navigation

Google can only discover links that are `a` elements with an `href` attribute, so clickable elements without one don't help discovery.

Instead of hashchange, use real paths

```
// Link: <a href="/products">Products</a> link.addEventListener('click', (event) => { event.preventDefault(); loadView('/products'); history.pushState({}, '', '/products'); });
```

**Fragments are fine for in-page jumps**Linking to a heading with `#setup` is normal and useful. The problem starts when a distinct page of content exists only behind a fragment. If it deserves to be found, give it a path of its own. See [URL structure](/glossary/url-structure).

_03_How it works

## Check it in 2 minutes

Prove the server ignores the fragment

```
curl -s https://developer.mozilla.org/en-US/ | wc -c curl -s 'https://developer.mozilla.org/en-US/#anything' | wc -c # curl drops the fragment, so the byte count matches
```

1. 01

### Find hash-based routes

Open the site, click through the main navigation, and watch the address bar. If views change only after a `#`, they're fragment-routed.
2. 02

### Compare with View source

Open a fragment-routed view's source. If the content isn't in the initial HTML, the view depends on JavaScript, so see [JavaScript SEO](/glossary/javascript-seo).
3. 03

### Check canonicals

Search your rel=canonical values for `#`. Any hit is a canonical Google generally won't support.

Sources · 4

## Every fact, linked and dated.

Official docs first. The date is when we last opened each page.

- mozilla.org
- google.com
- rfc-editor.org

1. 01 [URI fragment (MDN)](https://developer.mozilla.org/en-US/docs/Web/URI/Reference/Fragment) developer.mozilla.org · checked 2026-11-01
2. 02 [JavaScript SEO basics (Google Search Central)](https://developers.google.com/search/docs/crawling-indexing/javascript/javascript-seo-basics) developers.google.com · checked 2026-11-01
3. 03 [How to specify a canonical URL (Google Search Central)](https://developers.google.com/search/docs/crawling-indexing/consolidate-duplicate-urls) developers.google.com · checked 2026-11-01
4. 04 [RFC 3986, section 3.5 Fragment](https://www.rfc-editor.org/rfc/rfc3986#section-3.5) rfc-editor.org · checked 2026-11-01

Questions

## Asked a lot.

1 questions people ask next, answered from the sources on this page.

_01_ Does Google treat URLs with different fragments as different pages?

Google's documentation says it generally doesn't support fragments as canonical URLs and can't reliably resolve content that depends on them. Because the server receives the same request, treat fragment variants as one URL.

## Keep learning

[All glossary](/glossary)

[Learn Canonical HTTP header Crawling and indexing](/glossary/canonical-http-header) [Related JavaScript SEO Crawling and indexing](/glossary/javascript-seo) [Read next SPA SEO Crawling and indexing](/glossary/spa-seo) [Do Run a free site audit Free, about two minutes](/site-audit)

Nearby in glossary
[Unlinked brand mentions](/glossary/unlinked-brand-mentions) [URL length](/glossary/url-length)

More in Crawling and indexing
[Removals tool (Search Console)](/glossary/removals-tool) [Rendered HTML](/glossary/rendered-html) [Rendering](/glossary/rendering) [Robots meta tag](/glossary/robots-meta-tag) [Server-side rendering](/glossary/server-side-rendering) [Sitemaps report](/glossary/sitemaps-report) [SPA SEO](/glossary/spa-seo) [SSL certificate](/glossary/ssl-certificate) [SSR vs CSR](/glossary/ssr-vs-csr) [Subdomain vs subdirectory](/glossary/subdomain-vs-subdirectory) [Trailing slash in URLs](/glossary/trailing-slash) [unavailable_after](/glossary/unavailable-after) [URL fragment](/glossary/url-fragment) [URL Inspection tool](/glossary/url-inspection-tool) [URL parameters](/glossary/url-parameters) [URL structure](/glossary/url-structure) [User agent](/glossary/user-agent) [Video sitemap](/glossary/video-sitemap) [Web crawler](/glossary/web-crawler) [Web scraping](/glossary/web-scraping) [www vs non-www](/glossary/www-vs-non-www) [X-Frame-Options](/glossary/x-frame-options) [X-Robots-Tag](/glossary/x-robots-tag) [XML sitemap](/glossary/xml-sitemap)

Terms on this page
[JavaScript SEO](/glossary/javascript-seo) [Canonical URL](/glossary/canonical-url) [URL structure](/glossary/url-structure)

Free · 2 minutes

## Know the term. _Now check your site._

The free audit reads robots.txt, sitemaps, status codes, canonicals, redirects and structured data.

[Audit my site free](/site-audit)

Free, no card 60 seconds Nobody will call you

- **46** fixes shipped without a ticket Brightpipe
- **+212%** organic clicks in 90 days Ledgerly
