Forum Moderators: Robert Charlton & goodroi

Message Too Old, No Replies

Named Anchors for AJAX Naviagtion - does Google index them?

         

rockinthesixstring

10:16 pm on Oct 13, 2008 (gmt 0)

10+ Year Member



Hello Webmasters.
I have been doing some research on using Named Anchors (Default.aspx#ID=4) for AJAX site navigation. The biggest reason for this is that I want to add music to a website and dont want the music to restart on every postback.

My question is "do search engines index named anchors?"

The methodology of implementing it is not a problem, but the SEO could be a problem. My implementation would be as follows

use OnClientClick method on my menu to execute some JavaScript. That JavaScript will update a Hidden Input on my page... and my OnClick method in my ASP.NET Code Behind would poll the database for the ID field stored in the Hidden Input and update a Panel using ASP.NET AJAX.

tedster

11:05 pm on Oct 13, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No - Google (and other search engines) to not index named anchor or fragement identifiers as separate URLs. The URL stops at the # sign as far as indexing is concerned.

rockinthesixstring

12:00 am on Oct 14, 2008 (gmt 0)

10+ Year Member



I dont suppose you have any other thoughts on how to dynamically change the address bar without a full page postback.

tedster

12:15 am on Oct 14, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As I said above, the URL will be indexed up until the hash mark. This limitation is usually a very good thing. It avoids accidental duplicate URL problems and is one reason that a lot of standard AJAX these days is using the #. If you really intend to index each version of the URL, then a ? is the syntax to use -- but carefully. If the majority of the page's content stays the same, you could smack into a duplicate url issue.

Handling AJAX intelligently in regard to indexing is an evelving art. If you really want individual content indexed, then AJAX may not be the appropriate technology. A new dedicated URL might work better than a dedicated server call to replace just part of the page. And if there's only a few possible changes to be made, consider a show/hide div solution where all the content is in the initial source code. An iframe can also do the job in some situations.

What I'm saying is that everything doesn't need to be handled with AJAX - there are times it's just the right tool for the job and others where it is problematic.

[edited by: tedster at 2:15 am (utc) on Oct. 14, 2008]

vincevincevince

12:29 am on Oct 14, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Standard advice follows:

Return false from your onClick handler and have a valid non-JS URL in the href.

<a href="http://www.example.com/viewcontent.asp?id=401" onClick="return ajax_call(401)">Link</a>

The function ajax_call must return false. Viewcontent.asp can be a simple reimplementation of your JS parsing via ASP to return the finished page directly as HTML.

Search engines, and users who do not use javascript, will no excute 'onClick' but will instead visit the HREF portion of the link.

In my opinion, if you've not got support for non-JS systems, you have not finished the code yet - it is essential both for users and for search engines.

rockinthesixstring

1:34 am on Oct 14, 2008 (gmt 0)

10+ Year Member



Cool thanks for all the advice.