views:

41

answers:

2

I made some ajax sites in the past where I used ajax to get more of a desktop application feeling for my sites and also to keep the site maintainable. My strategy was making one index page and from there pulling in html content from some subpages. (So far I didn't use ajax to send data to the server.)

The problem that I ran into is this: I want the subpages to be readable by google since they contain valuable content but once they show up in google's results they lead to the naked html-file (no css nor Javascript). I solved this by putting a javascript redirect (window.location = ...) on the subpages so they lead to the correct page.

So as an example let's say I have a site at example.com with some javascript and css and a naked content page that should be loaded via ajax: example.com/content.html. Via ajax I pull in what I need from the content file but since my index.html contains href's to the content.html file (I want the content of my ajax site to be readable without Javascript) it will be indexed by google and gets listed in the search results. But I don't want people to see the naked html file. Hence the redirect that goes to the index page and gets handled by some Javascript to show the content as I want it to be showed.

I was wondering if there are nicer solutions to this problem or different approaches.

+1  A: 

Build on things that work

David Dorward
Interesting read but I already did that in my projects (example at ponyhof.be). All anchor tags point to real html sub-pages, things that work.The problem is the "sub-pages" obviously don't have css applied so if they show up in google (they are crawlable) the user will see an unstyled page.I always thought of javascript redirects as being a bit shady but I guess they are the only solution here.
metatron
The links should go to real, complete documents. The JS should request a different URI (e.g. `this.href + "?notemplate=true"`) to get the fragment instead of the page.
David Dorward
I see, that's definetely a sound solution.
metatron
+1  A: 

While I agree with David's answer, there's also this option for making your AJAX pages crawlable by Google.

It's a pretty new, unproven process, and it's definitely got its warts, but it's something at least.

Jason Hall
Interesting, I didn't know about that technique, but it's not really the answer I was looking for. I phrased my question a bit wrongly I'm afraid. My pages are already crawlable and show up in google's results. But once found by a user and clicked upon they bypass the javascript logic and the user ends up with an unstyled html-page. So I conclude the only solution is a dirty js redirect. Maybe they aren't as dirty as they seem...
metatron