Michael
Michael

Reputation: 33297

How to make SPA Ajax Applications without #! crawlable?

When you have a single page application (SPA) which contains mostly of JavaScript content that is loaded via Ajax google propose a guide on how to make such applications crawlable.

You have to use #! in your page fragments to make the fragments visible to the search engine.

www.example.com/ajax.html#!mainpage

Now, if you use the HTML5 PushState History API you can change the url to

www.example.com/ajax.html/mainpage

This url looks must nicer than the first one. Search engines can easily access the page since there is no hash bang # in the url. The problem is that it is still a JavaScript page the must be interpreted which search engines do not do.

  1. How can this ajax page be accessible to search engines?
  2. How does my server know if a search engine or a user browser tries to access the page?

I have the following ideas but no idea how to implement it or if there are any solutions.

Upvotes: 2

Views: 386

Answers (1)

Patrick
Patrick

Reputation: 1631

I think both of your ideas are on track.

Either way, you would need to catch on the server the search engin "?_escaped_fragment_=" as a proxy for "#!". For this, you may look at this SO and lookup GWT official reference.

For performance reason (the headless browser is slow, it may run beyond end of javascript completion), you can also cache the resulting static html pages (those that don't depend upon dynamic parameters like in your example) and serve those but then you need to be careful to keep them in sync when you upgrade your code to avoid being considered a Doorway Page.

Upvotes: 2

Related Questions