Question

I have AngularJS application already in production and I need to make it Google-friendly. I have read about Ajax crawling mechanism and I have following two problems:

1. Since I have backend written in Java, I have tried HtmlUnit to make static snapshots, but it didn't work well with AngularJS. How can I serve snapshots of my AngularJS pages using Java?

2. As I have mentioned, application is already published and it uses simple hash without !. E.g.: /#/about, /#/home. Is it possible to keep this scheme? Change to /#!/ would require modifications of all links and would break all existing links (posted on web).

Thanks in advance!

Was it helpful?

Solution

The SEO is always an issue with single-page application.

I suggest you make a quick implementation of Phantom.js to display already rendered page to google bots. Check out this link for more informations.

Phantom.js will be a gateway to which you redirect every indexing bot request, it will then render your app like a normal user will do, and then send back the rendered page to the bot.

Also, it would be better to change your /#/ to only /, it's better for your users and also SEO. You just need to redirect every request to the index.html page and to use '/#/' as fallback for old browser which doesn't support pushState.

You also have some paid solution like https://prerender.io/ which works beautifuly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top