Code Monkey home page Code Monkey logo

ajax-seo's Introduction

AJAX-SEO Bower Version

A simple server to provide rendered html to crawlers, for ajax sites.

How to use

prepare the web app

make sure it's "AJAX crawlable.", which means it adopts hashbang url schema. Read the google doc again if you don't understand.

prepare the server side

  1. Install PhantomJS, on Mac, you can: $ brew install phantomjs

    $ sudo apt-get install phantomjs  
    
  2. Start SEO Server

    $ phantomjs seo.js
    
  3. Setup nginx, add codes below into site configuration:

    if ($args ~ _escaped_fragment_) {
      rewrite ^ /snapshot$uri;
    }
    
    location ~ ^/snapshot(.*) {
      rewrite ^/snapshot(.*)$ $1 break;
      proxy_pass http://localhost:8888;
      proxy_set_header Host $scheme://$host;
      proxy_connect_timeout 60s;
    }
    
    

How to verify

$ curl http://yoursite.domain/page#!/id/12
$ ## verify it's fully rendered HTML

How to test your local app w/o nginx

$ ## if your app is running at http://localhost:3000
$ curl http://localhost:8888/page#!/id/12 --header Host:localhost:3000
$ ## verify it's fully rendered HTML

Notes

For index page of your site, you need to add this in HTML if you haven't:

<meta name="fragment" content="!" />

if you have trouble for https URLs, try this:

$ # phantomjs --ssl-protocol=any seo.js

see phantomjs options documentation

ajax-seo's People

Contributors

liuwenchao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ajax-seo's Issues

Getting response: <html><head></head><body></body></html>

Hello, Your solution looks damn good to solve SEO problem. I am trying to implement it to serve the angular app but getting the following response

<html><head></head><body></body></html>

The seo.js file is placed along with the index.html. The following curl command is used to get the html content.

curl localhost:8888/?_escaped_fragment_=/index.html

I have edited the index.html file for the meta tag. Did everything as you explained but not getting the actual response.

Example does not work?

First up, thanks for this! It gives me a much better idea of the right way to use phantomjs

First issue I encountered is the example command $ curl http://localhost:8888/page#!/id/12 --header Host:localhost:3000 - the ! is interperted by bash as part of history - this is fixed by running $ curl http://localhost:8888/page#\!/id/12 --header Host:localhost:3000 - note \!

after that - it still seems not to work, but has given me enough pointers, I should be able to fix it up for my situation!

setTimeout 10000 ?

Hi @liuwenchao and thanks for your nice job,

I feel curious about the setTimeout 10000.

page.onInitialized = function() {
       page.evaluate(function() {
            setTimeout(function() {
                window.callPhantom();
            }, 10000);
        });
    };

is-it for testing purpose ?

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.