Open almost any long guide, help centre or product page and you will find a URL with a hash in it: /pricing#enterprise, /docs#install, /#/products/42. Some of those hashes are harmless conveniences that help readers jump to the right paragraph. Others quietly hide entire sections of a website from Google, because the part of the address after the # is something Google Search generally ignores.
The trouble is that both kinds look identical in a browser bar. A marketing team sees a working link, a developer sees a working route, and nobody notices that Search Console only ever reports one URL where the site has fifty "pages". When rankings for those pages never arrive, the cause is rarely obvious.
This guide explains exactly what Google does with the fragment, which uses of # are safe and even helpful, which ones block indexing, how text fragments (#:~:text=) fit in, and how to move a hash-routed application to clean URLs without losing the traffic you already have.
The anatomy of a URL fragment and why browsers never send it
A fragment (also called a hash or anchor) is everything after the first # in a URL. In https://example.com/guide?ref=nav#step-3, the scheme is https, the host is example.com, the path is /guide, the query string is ref=nav and the fragment is step-3.
The fragment has one defining technical property: the browser does not send it to the server. When someone requests that URL, the server only receives /guide?ref=nav. The browser keeps #step-3 to itself and uses it after the page loads, either to scroll to an element with id="step-3" or to hand the value to JavaScript running on the page.
That property explains almost everything about fragments and SEO. Because the server sees the same request whatever the fragment says, every fragment variant of a URL is, from a crawler's point of view, the same document. Google treats the fragment as client-side state, not as an address for separate content.
| URL component | Example | Sent to the server? | Can create a separately indexed URL? |
|---|---|---|---|
| Path | /shoes/running/ | Yes | Yes |
| Query string | ?colour=blue | Yes | Yes (often a duplicate to manage) |
| Fragment | #reviews | No | Generally no |
| Text fragment directive | #:~:text=free%20returns | No (and stripped from what page scripts can read) | No |
The practical rule follows directly: if the content you want ranked only appears when a particular fragment is present, Google has no reliable way to request that content as its own page.
How Google treats fragments when it crawls and indexes
Google's own documentation is unusually direct on this point. In its guidance on URL structure it warns against building content around the hash:
“Don't use fragments to change the content of a page, as Google Search generally doesn't support URL fragments.”
— Google Search Central, URL structure best practices for Google Search
In practice this means three things:
- Fragment variants are folded into the base URL. Links pointing to
/guide#step-3and/guide#step-7are treated as links to/guide. Link signals consolidate on the base URL rather than being split. - Content that only exists for a given fragment is unlikely to be indexed as a separate result. If
/#/products/42and/#/products/43load different products through JavaScript, Google sees one URL: the home page. - Fragments do not cause duplicate content problems. This is the good news. You can add as many in-page anchors as you like without creating crawl waste or index bloat, unlike query parameters.
Google's measurement data follows the same logic. The Chrome UX Report, which supplies the field data for Core Web Vitals, strips query strings and fragments when it records page-level data, according to the CrUX methodology documentation. So the performance of /docs#install is reported against /docs.
One piece of history still confuses teams. Between 2009 and 2015 Google supported an "AJAX crawling scheme" in which #! ("hashbang") URLs were mapped to an ?_escaped_fragment_= version that the server could answer with pre-rendered HTML. Google announced it was deprecating that scheme in October 2015, and Search Engine Roundtable reported in December 2017 that Google would stop using it in the second quarter of 2018. If your application still relies on hashbangs and escaped-fragment snapshots, it is relying on a system that no longer operates.
Jump links that help readers without costing anything
Not every hash is a problem. On-page anchors are one of the most useful navigation devices on long pages, and they are completely compatible with good SEO. A table of contents at the top of a 3,000-word guide, "back to top" links, and links from a pricing table to the matching FAQ answer are all fragments used as intended: they point to a location inside content that already exists in the HTML.
Google also uses this structure itself. Search results sometimes show "Read more" deep links that send searchers straight to a section of a page. Google's snippet documentation lists conditions that make these more likely, including one that matters directly for anyone running scripts on page load:
“Avoid using JavaScript to control the user's scroll position on page load.”
— Google Search Central, Control your snippets in search results
The same page warns that if your site makes History API calls or changes window.location.hash on load, you should not remove the hash fragment from the URL, because that breaks deep linking. Some "smooth scroll" and consent scripts do exactly that, snapping every visitor back to the top or rewriting the URL after load.
A sound jump-link implementation looks like this:
- Give each target heading a short, stable, human-readable
id, such asid="shipping-costs". Avoid auto-generated IDs that change when an editor rewords the heading. - Link to it with a normal anchor:
<a href="#shipping-costs">Shipping costs</a>. Use descriptive link text, not "click here". - Keep the target content visible in the HTML. Content hidden behind tabs or accordions can still be indexed, but Google's snippet guidance prefers content that is immediately visible for deep links (see our guide to tabbed content and accordions).
- Offset sticky headers with CSS
scroll-margin-topso the heading is not hidden under the menu after the jump. - Do not let scripts reset scroll position or strip the hash during load.
For long pages the table of contents does double duty: it helps readers, and it gives Google clear section boundaries. The same principle applies to the sections that power deep links into specific content.
When a hash hides real pages: tabs, filters and hash-based routing
Problems start when the fragment stops pointing to a location and starts deciding what content is shown. Three patterns cause most of the damage.
Hash-based routing in single-page applications
Older Angular (AngularJS), Backbone, Ember and early React or Vue apps often used hash routing: example.com/#/about, example.com/#/services/roofing. The server always returns the same shell, and JavaScript reads the fragment to decide which view to render. To Google, the whole application is one URL. Every "page" competes for the same index slot, and only whatever renders at the root is likely to be associated with it.
Google's JavaScript SEO guide states the requirement plainly:
“For single-page applications with client-side routing, use the History API to implement routing”
— Google Search Central, Understand the JavaScript SEO basics
Tabs and filters that write their state into the hash
Product pages with #specifications and #reviews tabs are usually fine, because all tab content is present in the HTML and the hash only controls which panel is open. The risk appears when a tab fetches content only when clicked (for example, reviews loaded through an API call triggered by #reviews). Then the content may never be rendered for Googlebot, which does not click.
Faceted navigation is the opposite case. Some stores deliberately put filter state in the hash (/dresses#colour=red&size=12) to keep thousands of combinations out of the index. That is a legitimate choice if you do not want those combinations indexed, but it also means a valuable filtered page such as "red dresses" can never rank. The decision should be deliberate, not an accident of the JavaScript framework.
Campaign and tracking hashes
A few analytics and email tools append tracking data after a hash to avoid creating duplicate URLs. That is generally harmless for SEO, though it can break jump links if a page also uses anchors, and it can be stripped by redirects.
| Use of # | Example | SEO impact | Recommended action |
|---|---|---|---|
| Table of contents anchor | /guide#step-3 | Neutral to positive | Keep; use stable IDs |
| Tab state, content in HTML | /product#reviews | Neutral | Keep; make sure all panels render without clicks |
| Tab content loaded on click | /product#reviews via API | Content may not be indexed | Render content server-side or on load |
| Faceted filters in hash | /dresses#colour=red | Filtered views cannot rank | Promote valuable combinations to real URLs |
| Hash routing | /#/services/roofing | Whole app indexed as one URL | Migrate to History API routes |
Hashbang (#!) with escaped fragments | /#!/about | Relies on a retired Google scheme | Migrate to clean URLs with redirects |
Text fragments: the #:~:text= links you see in Google results
If you have clicked a featured snippet and landed on a page with a sentence highlighted in yellow, you have used a text fragment. The URL ends in something like #:~:text=free%20returns%20within%2030%20days.
MDN describes the feature simply:
“Text fragments link directly to specific text in a web page, without requiring the page author to add an ID.”
— MDN Web Docs, Text fragments
The syntax, per the MDN reference, is #:~:text=[prefix-,]textStart[,textEnd][,-suffix]. The :~: part is called the fragment directive, and browsers strip it during loading so page scripts cannot read it. Matching is case-insensitive, and if the browser cannot find the text (or does not support the feature) it simply loads the top of the page.
What this means for site owners:
- You do not need to do anything to enable them. They work on any page that contains the text, without IDs.
- They do not create new URLs for indexing. Like any fragment, they are client-side only.
- Exact wording matters for highlighting. If you rewrite the sentence Google is highlighting, the link still loads the page but the highlight disappears. That is not a ranking issue, but it is worth knowing when you edit pages that win featured snippets.
- You can style the highlight with the
::target-textCSS pseudo-element to match your brand. - Sites can opt out in Chromium browsers with the
Document-Policy: force-load-at-topheader, which MDN documents. Most sites have no reason to do this.
Text fragments are also a handy tool for your own work: linking a client or colleague to the exact sentence in a long Google document, or sharing proof of a claim in a competitor's page, without asking anyone to scroll.
Checking whether Google can see your fragment-driven content
Before rebuilding anything, confirm whether you actually have a problem. This diagnostic takes about half an hour on a typical site.
- Crawl the site with a crawler such as Screaming Frog (see our Screaming Frog guide). Count unique indexable URLs. If an application with dozens of distinct views produces only a handful of URLs, hash routing is likely.
- Search the HTML for fragment links. Use a custom extraction rule such as the XPath
//a[contains(@href,'#/')]/@hrefto list links that use hash routes, and//a[contains(@href,'#!')]/@hreffor hashbangs. - Inspect a hash URL in Search Console. Paste
https://example.com/#/services/roofinginto the URL Inspection tool. Google reports on the base URL, which is itself the symptom. - Compare rendered HTML. Google's JavaScript troubleshooting guide recommends URL Inspection or the Rich Results Test to see the rendered DOM. If the rendered home page contains only the home view, the other views are invisible.
- Check performance data. In the Search Console Performance report, filter by page. If impressions for "service" queries all land on the home page, Google is associating that content with the root.
Migrating from hash URLs to clean URLs without losing traffic
The fix for hash routing is to give every distinct view a real path, served by the server (or pre-rendered), and to route with the History API so the browser updates the address bar without a full reload. Modern versions of every major framework do this by default; React Router's BrowserRouter, Vue Router's history mode and Angular's default PathLocationStrategy all use paths rather than hashes.
The hard part is the old links. Because the fragment never reaches the server, you cannot redirect /#/about to /about with a server-side 301. The server only ever sees a request for /. The redirect has to happen in JavaScript on the root page.
<script>
// Runs early on the home page only
if (location.hash.indexOf('#/') === 0 || location.hash.indexOf('#!/') === 0) {
var path = location.hash.replace(/^#!?/, '');
location.replace(path); // replace() avoids an extra history entry
}
</script>
Google can follow JavaScript redirects when it renders a page, though a server-side 301 is always the stronger signal where it is possible. For more detail on how Google handles client-side redirects, see our guide to meta refresh and JavaScript redirects.
A migration plan that has worked well:
- Inventory every route. Export the router configuration and list every view with its intended clean path (for example
#/services/roofingbecomes/services/roofing/). - Make each path return real HTML with a 200 status. Configure the server (or hosting rewrites) so that a direct request for
/services/roofing/returns the right content, ideally server-rendered or pre-rendered. Our guide to server-side rendering versus client-side rendering covers the options. - Return 404 for paths that do not exist. Many single-page apps send 200 for everything, which produces soft 404s. Google's JavaScript guide suggests adding a
noindexrobots meta tag to error views when a true 404 status is impractical. - Give each page its own title, meta description and self-referencing canonical in absolute form, as Google's canonicalisation documentation recommends.
- Rewrite internal links to plain
<a href="/services/roofing/">elements. Google can only discover links that are<a>elements with anhref. - Add the client-side hash-to-path redirect on the root URL for old bookmarks and backlinks.
- Submit an XML sitemap listing only the new clean URLs (see our XML sitemaps guide).
- Update external links you control: social profiles, Google Business Profile, email templates, ad final URLs.
A worked example: a 40-view hash-routed brochure site
Hypothetical example for illustration. A building contractor's site is an older single-page app. It has a home view, 12 service views, 20 location views and 7 other pages, all on hash routes such as /#/services/loft-conversions. Search Console shows a single indexed URL, the home page, with around 9,000 impressions a month, mostly for the brand name and a few generic "builder near me" queries.
After migration, each of the 40 views has a server-rendered path, a unique title and a canonical. Here is how you might estimate the opportunity before committing developer time:
| Page group | Pages | Example query each could target | Assumed monthly impressions per page after indexing | Projected impressions |
|---|---|---|---|---|
| Services | 12 | "loft conversion cost" | 400 | 4,800 |
| Locations | 20 | "builders in [town]" | 150 | 3,000 |
| Other pages | 7 | "[brand] reviews", "planning permission guide" | 100 | 700 |
| Total new | 39 | 8,500 |
The per-page assumptions are placeholders: replace them with search volumes from your keyword tool and realistic positions. The point of the exercise is to show stakeholders that the pages currently have zero chance to appear, so even conservative assumptions justify the migration. Expect the new URLs to take weeks to be crawled and indexed; monitor them in the Page indexing report and watch for "Discovered – currently not indexed" on thin location pages.
Edge cases developers ask about
A few situations come up repeatedly in technical audits:
- Canonical tags with fragments. A canonical such as
<link rel="canonical" href="https://example.com/guide#top">is pointless; the fragment is ignored. Always canonicalise to the clean URL. - Sitemaps with fragments. Listing
/guide#step-3adds nothing. Sitemaps should list unique URLs only. - hreflang and fragments. Alternate URLs must be distinct pages; hash variants cannot represent language versions.
- Redirects and fragments. Browsers usually carry the fragment over a server redirect when the target URL has no fragment of its own, so
/old-guide#step-3redirected to/new-guidewill normally land on/new-guide#step-3. Keep heading IDs consistent when you migrate content so these jumps still work. - Analytics. GA4 page views use the page location, and default setups record the URL without treating hash changes as new pages unless enhanced measurement history-change tracking or custom events are configured. Hash-routed apps often under-report page views for that reason.
Large sites with many JavaScript views should also read our notes on SEO for large websites, where routing choices multiply in impact.
Questions developers and marketers ask about hash URLs
Does Google index content after the # in a URL?
Generally no. Google treats URL fragments as client-side state and folds them into the base URL. Content that only appears for a specific fragment is unlikely to be indexed as its own result, which is why Google recommends the History API for JavaScript routing.
Do jump links or anchor links help SEO?
They help users navigate long pages and give Google clear section structure, which can support “Read more” deep links in results. They do not create new indexable URLs, so they carry no duplicate content risk.
Can I 301 redirect a hash URL like /#/about to /about?
Not on the server, because browsers never send the fragment to the server. Use a small JavaScript redirect on the root page that reads location.hash and calls location.replace() with the matching clean path.
Should I remove text fragments (#:~:text=) from my analytics or links?
There is nothing to remove. Browsers strip the fragment directive during loading, it creates no new URL and it does not affect indexing. You can style the highlight with the ::target-text pseudo-element if you wish.
Is hashbang (#!) still supported by Google?
No. The AJAX crawling scheme that mapped #! URLs to _escaped_fragment_ snapshots was deprecated in 2015 and Google stopped using it in 2018. Hashbang sites should migrate to clean, server-resolvable URLs.
Where to start with hash URLs on your site this week
Start by sorting your fragments into the two groups this guide describes: anchors that point to content already in the HTML (keep them, give them stable IDs) and fragments that decide what content is shown (treat them as a routing problem). A quick crawl plus an extraction rule for #/ and #! links will tell you which group you are in within an hour.
If you find hash routing on revenue pages, plan the migration as you would any URL change: inventory, real paths with 200 status, canonical tags, client-side redirects for old links and a fresh sitemap. If you are rebuilding on a modern framework anyway, our guide to Next.js SEO shows how clean routes, metadata and sitemaps fit together, and JavaScript SEO fundamentals covers rendering in more depth.
Want a second pair of eyes on a JavaScript site that is not getting indexed? Our technical SEO team audits rendering, routing and indexing together. Get a quote and tell us which URLs are missing from Google.
Further reading on url fragments seo
- Removing AMP Without Losing Traffic
- Field Data vs Lab Data: Why Your PageSpeed Scores Disagree
- Responsive Images With srcset and sizes: Serve the Right Image to Every Device
Sources for this URL fragments guide
- Google Search Central: URL structure best practices for Google Search
- Google Search Central: Understand the JavaScript SEO basics
- Google Search Central: Control your snippets in search results
- Google Search Central: Fix Search-related JavaScript problems
- Google Search Central: How to specify a canonical URL
- MDN Web Docs: Text fragments
- Google Search Central Blog: Deprecating our AJAX crawling scheme (October 2015)
- Search Engine Roundtable: Google will render AJAX and stop using old AJAX crawling scheme (December 2017)
- Chrome for Developers: CrUX methodology




