0

I'm making an entire site using angular. Using routes the urls come out to www.mysite.com/#/mypage. I'd like this to change to www.mysite.com/mypage without navigating away from the page and do screenshots for google bots. How can I do this with angular?

micah
  • 7,596
  • 10
  • 49
  • 90
  • Maybe you can try html5mode http://docs.angularjs.org/guide/dev_guide.services.$location – Chandermani Jan 24 '14 at 03:26
  • This post will help you http://stackoverflow.com/questions/16677528/location-switching-between-html5-and-hashbang-mode-link-rewriting – Shidhin Cr Jan 24 '14 at 04:10
  • And if you're looking for a complete SEO solution, go for this http://www.yearofmoo.com/2012/11/angularjs-and-seo.html – Shidhin Cr Jan 24 '14 at 05:31

1 Answers1

0

You need to follow Google rules regarding SPA crawling.

1) Enable Angular HTML5 mode and hashbang prefix with :

$locationProvider.html5Mode(true).hashPrefix('!');

So you will have standard urls (www.mysite.com/mypage) on modern browser for your users, and hashbangs urls (www.mysite.com/#!/mypage) for old browsers and crawlers.

2) Add <meta name="fragment" content="!" /> to your head

3) For each angular pretty url ( #!/mypage/key=value) your server also need to serve ugly urls (#!/mypage?_escaped_fragment_=key=value) with an HTML snapshot. You can use PhantomJS for this.

And you are done, but for best results also implement canonical urls.

Rémy DAVID
  • 4,343
  • 6
  • 25
  • 27