Hi folks,
I'm a relative newbie to programming (less than a year), and am having
my first experience with submitting a site for indexing. Like many
others, I find the grace and functionality of AJAX very appealing, but
have run into the search engine problem associated with it.
A brief summary of the problem:
1. AJAX loaded content is not indexed by google.
2. Creating a duplicate site or content for indexing purposes is
BAD.
Solutions I Have Read About:
1. Do not use AJAX for loading static content.
2. Be willing to not have your content indexed, and still use
AJAX.
Considerations:
1. Provide access for non-JS enabled browsers.
My Solution:
I have a PHP driven site utilizing a main index.php with a dynamic
content div. (IE the div doesn't have anything in it when the page is
initially loaded).
On JQuery's document.ready or any other necessary event handler,
static content is called from the server via AJAX and loaded into the
dynamic div.
Here is the heart of my solution: The actual content is completely
formatted as an HTML document, including a DTD. In fact, the content
independently validates as XHTML 1.0 strict.
Within the head section, I place a JS function fired on document.ready
which determines if the browser window is at the index.php href. If it
is, then nothing happens. If the browser isn't at that location, it
loads the index.php page and passes a parameter to load the
appropriate dynamic content.
When the page is loaded, the content displays correctly within the
dynamic div.
Of course, if the user (or the robot) does not have JS enabled,
nothing at all happens and they view the content page in a simple HTML
format.
All of the dynamic content pages are made available through an HTML
sitemap for users and an XML sitemap for search engines. Here is the
relevant JS code:
<code>
// the showWhat parameter is the filename of the content, for instance
homework.html .
function showMe(showWhat) {
if (window.locatiuon.href != "http://website.com/index.php") {
window.location.href = "http://website.com/index.php";
showContent(showWhat);
}
}
function showContent(whatContent) {
//using JQuery
//#dynamic content is the id of the div
$('#dynamic_content').load(whatContent);
}
</code>
Here is my question:
Is there any reason this is not a viable, acceptable method of using
AJAX with static content? It is indexable, it does not duplicate
content, and the content can be viewed by people that do not have JS
enabled.
I tested this on:
Firefox 2/3
IE 6/7
Safari 3
Netscape 9
Opera 9
Konqueror 3
Thanks for any answers/comments/suggestions/improvements. Keep in mind
I'm a newb.
Regards,
Mad Mouser