Site icon Search Engine People Blog

Does Google Index My # Anchor Links?

named-anchor-links

Updated: John Mueller pointed out how HTML5 can be used for AJAX driven sites. See below.

Summary: yes, Google indexes on-page anchors and their on-that-same-page content but no Google doesn't by itself index content that would additionally be retrieved besides what's already on the page.

And no Google essentially doesn't index anchor links.

Anchors -- also called named anchors -- are places in a page or document you want to be able to directly link and jump to.

Anchor Links are clickable hyperlinks that lead directly to a named anchor. You can recognize them; at the end of the URL they have a pound/hash sign (#) followed by a name or number (called a fragment identifier. Like so: https://www.w3.org/TR/html401/intro/intro.html#fragment-uri

How Do I Make Named Anchors?

  1. By putting an <a name> link in your page:
    • <a name="section-name"></a>
    • <h1><a name="section-name">My Section</a></h1>
  2. By using an ID attribute for an element on your page:
    • <h1 id="section-name">My Section</h1>
    • <div id="section-name">My Section</div>

    In both cases the name needs to be unique.

    Does Google Index Named Anchors?

    Trick question. Google indexes complete web pages, not parts of web pages. So once it has indexed your page that contains named anchors, it has also automatically indexed your named anchors.

    Since 2009 Google at its own discretion may show a named anchor under a search result snippet if the named anchor is relevant to the search. To have that happen the page should also have some sort of table of content linking to the named anchors.

    No.

    Why not?

    When you click an anchor link your browsers asks the website for the whole document at the URL you just clicked minus everything starting from #:

    In other words: the browser never send the part after the # to the server and the server never knows about it.

    The automated "browser" that Google uses acts just like that and asks for the URL without the #

    No.

    If a page pulls in and shows different content depending on the # named anchor links clicked, Google does not see and index that content.

    Why not?

    In the above setup:

    For most practical purposes you can start from the idea that Googlebot (and other search crawlers) do not execute JavaScript. So because of the way browsers work (see above) Google's crawler cannot asks for the URL including the #: anchors in URLs never leave the browser, are never sent to the server, and if they were the server would have no idea what to do with them.

    In short: the web simply doesn't work like that.

    How Can I Make Dynamic AJAX Anchor Links Crawlable?

    Also in 2009 Google proposed a way to make AJAX content crawlable and indexable.

    The proposal relies on a 3 step process:

    1. Change your dynamic AJAX anchor links from #whatever to #!whatever <--- notice the exclamation mark!
    2. When Google finds a link on the web that goes #!... Google will rewrite that part of the URL to ?_escaped_fragment_= followed by whatever was after your #
    3. It will then request this URL from your server

    Example:

    Updated: John Mueller points out that HTML5's pushState() makes it possible to build AJAX driven sites using good old-fashioned, regular links.

    Conclusion

    1. be written as #! instead of just #
    2. be available on your server at the location ?_escaped_fragment_?=

      OR

    3. use regular links with HTML5's pushState() instead