SEO and ajax loaded content link

I need some help to better understand SEO with ajax loaded content.

Here the context:

I have a single.php where content is dynamically generated (with php and an xml database) for each single post.

I load a container of this single.php inside my index.php page via ajax. Here the working script:

$.ajaxSetup({cache:false});
    $(".phplink").click(function(){
        var post_link = $(this).attr("href");
        window.location.hash = "!"+ post_link ;
        $("#ajaxify_container").html("loading...");
        $("#ajaxify_container").load('single.php?blog_no='+post_link+' #container');
    return false;
}); 

$(window).hashchange( function(){
var hash = window.location.hash;
var hash = location.hash.replace("#!","");

    if(hash != '') { 
        var post_link = hash;
        $("#ajaxify_container").html("loading...");
        $("#ajaxify_container").load('single.php?blog_no='+post_link+' #container');    
    } 
    else {
        $.get(hash, function (data) {
        $("#ajaxify_container").html('');   
        });

    }
});

$(window).hashchange();

An example of a link in index.php (when I click on a link I've got in url website.com/#!12) :

<a class="phplink" href="12">Post 12</a> 

And in my .htaccess file I added this lines to rewrite properly the url:

Options +FollowSymLinks
RewriteEngine on
RewriteRule /([0-9]+)$ /single.php?blog_no=$1

Everything works fine... (by the way, my single.php is SEO friendly "alone" and works without javascript)

However, by using ajax like this, with dynamic php page, is it still SEO friendly? I know that ajax is difficult to be crawled. What is the best way to have a good (not the best, something correct) SEO with ajax content?

Regarding the structure of the link, I don't fully understand what google bot will crawl. Because of the href="12" , so the dynamic href="/single.php?blog_no=12" . In the web browser :

  • website.com/single.php?blog_no=12 and website.com/12 load only my single.php page
  • website.com/#!12 load my index.php page with a container loaded from website.com/single.php?blog_no=12
  • Of course I only want that google crawls the hashbang url...

    (EDIT: if I open the link in a new tab with right click, it loads the single.php (that I don't want). It seems to be a normal behavior but...I want to prevent it)

    Sorry for my English, I'm French.


    Dynamically loaded content is generally hard to get right from an SEO perspective. Your description is a little confusing, but I think I have an idea of what you're looking for.

    First of all, there are mainly two ways with which Google finds out about pages on your site:

  • A Sitemap (Google likes XML sitemaps) - A file that tells Google every page on your site to index
  • Links - Google will follow any internal link on pages it tries to index unless they are marked with rel="nofollow"
  • There's also links in and some other stuff, but for the purposes of this explanation...lets ignore those.
  • Anyway, unless you're explicitly telling Google that website.com/single.php?blog_no=12 exists, it's going to have a hard time finding it. To be honest, I'm not sure how Google will handle something like href="12" , it may try to follow that link to website.com/12 which may effect your ranking if there is nothing there. So in the end, you might want to add rel="nofollow" to your AJAX trigger links.

    A good way to handle AJAX and dynamically loaded content is to make sure fallbacks are in place, for example if you have something like href="single/12 set up to load some content with AJAX, you should also have a fallback page that doesn't use JS/AJAX. This ensures that both search engine bots, and users without Javascript can see that content if it otherwise wouldn't have been visible anywhere else.

    Last small tidbit, if you test your links on something like http://www.dnsqueries.com/en/googlebot_simulator.php and they turn up with errors, or blank pages (search engine bots don't use javascript) you should nofollow those links, or setup fallback pages

    Nevermind...this is the last thing. You should go a couple steps further with your htaccess rewrite to make your URLs completely clean of query strings. For example website.com/single/blog/12 is better than website.com/single.php?blog_no=12 for both SEO and users.

    链接地址: http://www.djcxy.com/p/62518.html

    上一篇: SEO与单页网站

    下一篇: SEO和ajax加载的内容链接