When helping clients optimize their websites, we’re often asked about hash symbols in URLs and how they affect SEO. Are they ignored by Google? How should they be used? The answer is…well, it depends. Here’s a quick explanation:
A hash sign (#) in a URL is referred to as a fragment. Historically, URL fragments have been used to automatically set the browser’s scroll position to a predefined location in the web page. In that sense, if a URL refers to a document, then the fragment refers to a specific subsection of that document.
Any information that appears after the first hash symbol in a URL is referred to as the fragment identifier – sometimes also called an anchor tag. By default, the fragment identifier is interpreted only by the local web browser and is typically not passed to the remote web server. For example, the following two links would both be considered requests for the same document by the web server:
Since the fragment identifiers in the example URLs above signify two different locations in the same page, search engines like Google will consider them both to refer to a single search result: www.company.com/fruits.html
For this reason, it’s important not to use fragments as a way to represent what should instead be different pages. In short, if you want Google to crawl two different pages and index them separately, you’re better off simply using two distinct URLs without fragments.
So, the question is, how does Google index distinct content within AJAX style pages? After all, we just said that Google will not consider the fragments in the URLs. The answer is Google has provided a syntax for working around this problem. It’s known as the “hash bang” syntax. By putting an exclamation point immediately after the hash sign, you're telling Google that the fragments are not used for traditional scroll positioning but instead for loading separate content variations that should be crawled. With that approach, our example URLs with fragments could indeed be crawled and seen by Google. Our example URLs might then look like this:
Remember, if you’re not using this special syntax, analytics reporting systems like Google Analytics may not be configured to track clicks on fragment links in your site. To ensure tracking works, either structure your content with distinct URLs or configure your Google Analytics code to also track fragment clicks.
Have another 60 seconds to spare? Learn about: