Question

I've googled a little bit but I found very little information if ui.routes works or not with html5mode=true and $locationProvider.hashPrefix('!'); I mean if you use ui-router you can make your site crawlable by ie google ? Can you give me a hint, please ?

Was it helpful?

Solution

ui.router does work with $locationProvider.html5Mode(true).hashPrefix('!'); It will use HTML5 mode when the browser supports it, or fall back to hashbang if there is no support. The hashbang will look something like:

http://www.mysite.com/#!/mydirectory/file.html

You will also need to include a meta tag to help google know about the URL fragment

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

Doing all of this helps search engines determine how to access your precompiled content, but you will still need to generate and supply it. Here is some good information on how the SEO part will work if you haven't already seen this: https://developers.google.com/webmasters/ajax-crawling/docs/specification?hl=fr-FR

OTHER TIPS

Yes, in your sitemap you can include the pages you want the search providers to crawl.

For instance either of these would be acceptable:

http://www.example.com/!/colorwheel/green
http://www.example.com/colorwheel/green

In a sitemap.xml it would look like this:

<url>
    <loc>http://www.example.com/colorwheel/green/</loc>
    <changefreq>daily</changefreq>
    <priority>1.00</priority>
</url>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top