Making javascript heavy sites crawlable / SEO with Prerender.IO / Getting started with Prerender.io for java sites

Setup prerender node server:
  1. git clone https://github.com/prerender/prerender.git
  2. cd prerender/
  3. #build and install
  4. # you will need nodejs's npm utility
  5. npm install
  6. node server.js

Indicate to the crawler that your site supports the AJAX crawling scheme :

replace all hash("#") with hash-bang("#!")

To handle pages without hash fragments put this in those pages
<meta name="fragment" content="!">

pom.xml :
//add this survlet filter( https://github.com/greengerong/prerender-java ) in your pom.xml:

  1. <dependency>
  2. <groupId>com.github.greengerong</groupId>
  3. <artifactId>prerender-java</artifactId>
  4. <version>1.6.2</version>
  5. </dependency>

web.xml :

  1. <filter>
  2. <filter-name>prerender</filter-name>
  3. <filter-class>com.github.greengerong.PreRenderSEOFilter</filter-class>
  4. <init-param>
  5. <param-name>prerenderServiceUrl</param-name>
  6. <param-value>http://localhost:3000</param-value>
  7. </init-param>
  8. <init-param>
  9. <param-name>crawlerUserAgents</param-name>
  10. <param-value>yourOwnCrawler</param-value>
  11. </init-param>
  12. <init-param>
  13. <param-name>extensionsToIgnore</param-name>
  14. <param-value>.xml</param-value>
  15. </init-param>
  16. </filter>
  17. <!--default crawlers "googlebot", "yahoo", "bingbot", "baiduspider",
  18. "facebookexternalhit", "twitterbot", "rogerbot", "linkedinbot", "embedly" -->
  19. <filter-mapping>
  20. <filter-name>prerender</filter-name>
  21. <url-pattern>/*</url-pattern>
  22. </filter-mapping>


//prerender-java client bug 1.6.2
you have to include this tag
<init-param>
            <param-name>extensionsToIgnore</param-name>
            <param-value>.xml</param-value>
        </init-param>
//for 1.6.3 this is not required, but it's not yet in central maven repository

all Other clients list :
https://github.com/prerender/prerender#middleware

Testing:

git clone https://github.com/ahmedmohiduet/ng-prerender-demo.gitcd ng-prerender-demo
mvn clean install tomcat7:run


curl -A "GoogleBot" http://localhost:9966/ng-prerender-demo/
#don't forget to put / at the end
curl http://10.0.0.52:9966/ng-prerender-demo/
#note the difference

you can also show them sample content:
http://localhost:3000/http://www.flipclub.com/card/422/Archaeology-1 
or
http://service.prerender.io/http://www.flipclub.com/card/422/Archaeology-1 

You can also use service : http://service.prerender.io/


Prerender caches :

* In-memory html cache (just uncomment this line at https://github.com/prerender/prerender/blob/master/server.js#L18 and in-memory cache will b enabled.)
* Amazon s3
* Redis Cache
* Your Own Implementation ( Example : https://github.com/lammertw/prerender-mongodb-cache )
* More.*..

It's paid version provides automatic caching of pages and persistent cache automatically gets synchronized. 

No comments:

Post a Comment