Angularjs website not indexing on google

本秂侑毒 提交于 2019-12-25 03:17:24

问题


I developed a large angularjs application with more than 20 pages and add some SEO tags. But it is not functioning well. Most of content of the pages also populate using javascript. This is how I implemented SEO tags for each pages.

app.js

(function() {

var app = angular.module('myApp', ['ngRoute', 'ngSanitize', 'angular-flexslider']);

// config route
app.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
    var baseUrl = "partials/";

    $routeProvider.when('/', {
        title: 'Title 1',
        metadescription: "Description 1",
        metakeywords: "Keyword 1",
        templateUrl: baseUrl + 'home.html',
        controller: 'homeCtrl'
    })
    .when('/page1', {
        title: 'Title 2',
        metadescription: "Description 2",
        metakeywords: "Keyword 2",
        templateUrl: baseUrl + 'page1.html',
        controller: 'page1Ctrl',
    })

    .otherwise({
        redirectTo: '/'
    });

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

app.run(['$location', '$rootScope', function ($location, $rootScope) {
    $rootScope.$on('$routeChangeSuccess', function (event, current, previous) {
        $rootScope.title = current.$$route.title;
        $rootScope.metadescription = current.$$route.metadescription;
        $rootScope.metakeywords = current.$$route.metakeywords;

    });
}]);

}());

Meta tags of the html have implemented as follows

<!DOCTYPE html>
<html lang="en" ng-app="lennonsApp">
<head>
<base href="/">
<meta charset="utf-8">
<title ng-bind="title"></title>
<meta name="description" content="{{metadescription}}">
<meta name="keywords" content="{{metakeywords}}">
<meta name="fragment" content="!">
</head>

<body>
   Content goes here.....
</body>
</html>

All the meta tags data bindings are working properly when page loads.But even after one month my website is not searching in search engines. This web site is hosted on IIS server. My questions: 1).Is this method working on search engines? 2).Do I need to do any other specific configurations for IIS server for angularjs application? 3).Can any one recommend any other method support SEO

Thanks in advance

Edit I tried google.com site:[domain name], none of the seo tags implemented as above is not effected.

Edit Are there any thing to do with IIS server ?


回答1:


Search engines tend not to execute JavaScript.

You need to have "real" pages generated server side for the benefit of search engines and users for whom the JS fails for any reason. Then use pushState (Angular can do this via its routes) to map Angular pages onto server generated pages.

You can take an isomorphic approach to the problem and write your JS so it can run server side or client side (which will probably involve running Node.js either instead of IIS or using IIS as a proxy).

Even then, meta keywords are almost always ignored and meta descriptions are usually ignored in favour of analysing the actual content.




回答2:


SEO implementation on SPAs is not trivial and not all search engine support it currently i think google, and maybe bing are able to crawl SPA's but some work needs to be done for that. there are several methods you can do this:

1 use !# for your angular routes instead of  just #
2 use html5 routes instead of # routes
3 detect crawlers on your server and serve the metadata
4 create snapshots of your site and serve them 

basically those are most of your options you can find more details in these articles

http://www.yearofmoo.com/2012/11/angularjs-and-seo.html https://developers.google.com/webmasters/ajax-crawling/



来源:https://stackoverflow.com/questions/28301663/angularjs-website-not-indexing-on-google

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!