I’m building an AJAX app which animates in content dynamically. Since all links are hashtags and I want to index my pages on other engines besides Google my idea is so:
- When coding links, use physical local urls (ie, href=”/foo/bar.php”)
- On page load, replace all links with hashtag, (ie, href=”#foo/bar”)
The idea is that the content will be loaded from /foo/bar.php if the visitor is a crawler or has JS-disabled. Otherwise, it will load in via AJAX so I can animate it in etc.
Would Google and other search engines be able to crawl my pages, since when they read in the links they point to physical locations (or php pages which load in data from db). Is this SEO friendly? Would this still violate Googles adsense TOS if I were to then include ads? If no, are there other solutions (besides not using AJAX – I need it) that will allow me to have a SEO friendly purely AJAX site/app?
That is a good way to do “graceful enhancement”. Works without JavaScript, works better with.
Just make sure those /foo/bar.php links actually work and directly provide (i.e. not via ajax) the information that #foo/bar would have displayed.
I would drop the .php extension and use so the two links are very similar:
Non Javascript Link = http://domain.com/foo/bar
Javascript Link = http://domain.com/#foo/bar
I think html5 is introducing a way to drop the # so you can live with the one URL for everything. I have to go so can’t look it up now.