简体   繁体   English

angular.js seo - 谷歌索引

[英]angular.js seo - google indexing

my current html looks like this: 我目前的HTML看起来像这样:

<title ng-bind="title">Loading</title>
<meta name="description" content="[[description]]">
<base href="/">
<meta name="fragment" content="!">

angular.js config: angular.js配置:

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

I thought it's enough to let the googlebot index site correctly. 我认为这足以让googlebot索引网站正确。 But nope, it's not taking correct title or description. 但不,它没有采取正确的标题或描述。 If I run "fetch as googlebot" site renders correctly..What should I do? 如果我运行“获取谷歌机器人”网站正确呈现..我该怎么办?

I don't think that you need to prerender your pages for the Google crawler anymore. 我认为您不再需要为Google抓取工具预呈现您的网页了。 A while back it started taking note of the javascript changes. 不久之后,它开始注意到javascript的变化。

I've actually answered a question about AngularJS seo that will help you here: 我实际上回答了一个关于AngularJS seo的问题,它可以帮助你:

Look for my answer on the above link. 在上面的链接上查找我的答案。 I've also provided a directive that might be useful to you. 我还提供了一个可能对你有用的指令。

By the way, are you sure you are using the angularjs expression properly? 那么,你确定你正确使用angularjs表达式吗? You have decription using [[]] normally it is {{}} 你有[[]]的解密通常它是{{}}

You need a prerendering engine to render the HTML for the bot. 您需要一个预呈现引擎来呈现机器人的HTML。 Read something here: https://scotch.io/tutorials/angularjs-seo-with-prerender-io 在这里阅读一些内容: https//scotch.io/tutorials/angularjs-seo-with-prerender-io

And here about the escaped_fragment the bot uses to crawl your site: https://developers.google.com/webmasters/ajax-crawling/docs/specification?hl=en 这里是关于机器人用来抓取您网站的escaped_fragmenthttps//developers.google.com/webmasters/ajax-crawling/docs/specification?hl = escaped_fragment

Sometimes Google will ignore the information provided in title or meta tags. 有时,Google会忽略标题或元标记中提供的信息。 But it looks more like a technically problem. 但它看起来更像是一个技术问题。

I would at least use ng-content-attr instead of writing it directly into the meta content attribute. 我至少会使用ng-content-attr而不是直接将其写入元内容属性。

ng-attr-content="{{description}}"

Maybe Google extract your title information before anuglar has replaced it with the right string! 也许Google会在anuglar用正确的字符串替换它之前提取你的标题信息!


Another way is to use a directive that takes care of this for you. 另一种方法是使用指令来处理这个问题。 luckily i just wrote one.. just go ahead and try, you'll see with this setup google will recognize your title! 幸运的是,我只是写了一个..只是继续尝试,你会看到这个设置谷歌识别你的标题! https://github.com/w11k/w11k-angular-seo-header/blob/master/angular-seo-header.js https://github.com/w11k/w11k-angular-seo-header/blob/master/angular-seo-header.js

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM