Skip to main content
capital P dangit
Source Link
EAMann
  • 32.2k
  • 9
  • 88
  • 147

Making my AJAX powered WordpressWordPress Crawlable

I read the following and try to apply this scheme to my website running WordpressWordPress: http://code.google.com/intl/fr-CA/web/ajaxcrawling/index.html

In order to provide the crawler with the needed ?_escaped_fragment_= I used a WordpressWordPress hack I've found on the net: http://www.wordpress-fr.net/support/sujet-54810-add-action-parse-request and now the GoogleBot can see the content of my AJAX powered pages. I thought it was all done.

So my guess is that I could maybe use a similar php function to serv the HTML snapshots instead of using the WordpressWordPress hack but I would need to adapt it to WordpressWordPress. The problem is that I'm no programmer and I did my best so far.

Making my AJAX powered Wordpress Crawlable

I read the following and try to apply this scheme to my website running Wordpress: http://code.google.com/intl/fr-CA/web/ajaxcrawling/index.html

In order to provide the crawler with the needed ?_escaped_fragment_= I used a Wordpress hack I've found on the net: http://www.wordpress-fr.net/support/sujet-54810-add-action-parse-request and now the GoogleBot can see the content of my AJAX powered pages. I thought it was all done.

So my guess is that I could maybe use a similar php function to serv the HTML snapshots instead of using the Wordpress hack but I would need to adapt it to Wordpress. The problem is that I'm no programmer and I did my best so far.

Making my AJAX powered WordPress Crawlable

I read the following and try to apply this scheme to my website running WordPress: http://code.google.com/intl/fr-CA/web/ajaxcrawling/index.html

In order to provide the crawler with the needed ?_escaped_fragment_= I used a WordPress hack I've found on the net: http://www.wordpress-fr.net/support/sujet-54810-add-action-parse-request and now the GoogleBot can see the content of my AJAX powered pages. I thought it was all done.

So my guess is that I could maybe use a similar php function to serv the HTML snapshots instead of using the WordPress hack but I would need to adapt it to WordPress. The problem is that I'm no programmer and I did my best so far.

Tweeted twitter.com/#!/StackWordPress/status/122975453941202944
Post Migrated Here from stackoverflow.com (revisions)
Source Link
Gab
  • 253
  • 3
  • 18

Making my AJAX powered Wordpress Crawlable

I read the following and try to apply this scheme to my website running Wordpress: http://code.google.com/intl/fr-CA/web/ajaxcrawling/index.html

If you visit my website at http://www.visualise.ca/ you will see that it loads the posts within the home page and the url becomes http://visualise.ca/#!/anne-au-cherry when this post is loaded. A static version of the same content is available for the crawler at http://visualise.ca/anne-au-cherry but if a visitor using a browser visits it he will be redirected to http://visualise.ca/#!/anne-au-cherry (this is done with javascript).

In order to provide the crawler with the needed ?_escaped_fragment_= I used a Wordpress hack I've found on the net: http://www.wordpress-fr.net/support/sujet-54810-add-action-parse-request and now the GoogleBot can see the content of my AJAX powered pages. I thought it was all done.

But when I paste a post link to Facebook (i.e.) it is unable to read the content of the page so I guessed that my website isn't really respecting the scheme described in the Google documentation since Facebook is supporting it (If you paste http://twitter.com/#!/gablabelle it will work). So since I'm using the jQuery.address plugin to get my hashbang (#!) I went to their website and downloaded their sample files to see what were the differences between their files and mine and realized that they were probably using a php function to create the needed HTML snapshots: https://github.com/bartaz/jquery-address/blob/master/samples/crawling/index.php because this is why, I guess, Facebook can't read mine.

<?php

    error_reporting(E_ALL ^ (E_NOTICE | E_WARNING));
    
    $fragment = $_REQUEST['_escaped_fragment_'];
    $file = 'data/' . (isset($fragment) && $fragment != '' && $fragment != '/' ? preg_replace('/\//', '', $fragment) : 'home') . '.xml';
    $re = '/(^<[^>]*>)|(\n|\r\n|\t|\s{2,4})*/';
    
    $handle = fopen($file, 'r');
    if ($handle != false) {
        $content = preg_replace($re, '', fread($handle, filesize($file)));
        fclose($handle);
    } else {
     $content = 'Page not found!';
        header(php_sapi_name() == 'cgi' ? 'Status: 404' : 'HTTP/1.1 404');
    }
    
?>

So my guess is that I could maybe use a similar php function to serv the HTML snapshots instead of using the Wordpress hack but I would need to adapt it to Wordpress. The problem is that I'm no programmer and I did my best so far.

My post are in this format: http://visualise.ca/#!/anne-au-cherry and the static version is available at http://visualise.ca/anne-au-cherry (Where anne-au-cherry is the slug of the post and changes depending on the page we are viewing).

So my question is could someone confirm that I'm on the right path and if possible also help creating that php function?

Many thanks for your time and help!