Question

First of all i am angular noob. I have a blog(http://naren.me) hosted in appengine and am using angularjs.

When i search "naren.me is python" in google, I see search result showing "Loding..." text, the text which is supposed to be displayed before ng-view loads.

enter image description here

When i generate sitemap for my site i don't see any angular redirected URLs at all. Am i missing something ? Here is the angular app.js file of my site. https://github.com/Narengowda/naren.me/blob/master/static/angularBlogFiles/js/app.js

Was it helpful?

Solution

Google bot and other cralwers can't execute javascript, they will request your page and just index whatever is there in the html. You can read more about it here Google's Crawler Guidelines

What you have to do is provide to Google and other search engines a static version of your website

You have some alternatives to solve this problem.

Paid service

This is the easiest way to generate and serve google with a static version of your website, here are some providers prerender.io, Brombone, seo4ajax, you can google for more providers.

Some of them have a free plan that would fit your needs better.

Make your own service to generate static web pages

You can build your own solution to generate your static pages learn here.

OTHER TIPS

The new way of doing this is to include in your angular.module('app').config function. (usually app.js)

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

Then in your index.html you'll want

<base href="/#!">
<meta name="fragment" content="!" />

between your tags.

finally, you'll need to edit your .htaccess (apache) with something like:

Options +FollowSymLinks
IndexIgnore */*

RewriteEngine on

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_URI} !/api
RewriteRule ^.*$ - [NC,L]

# otherwise forward it to index.html 
RewriteRule ^app/(.*) /app/#/$1 [NC,L]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top