简体   繁体   English

如何让Google在Angular.js应用中为动态标题编制索引

[英]How to get Google to index a dynamic title in an Angular.js app

Google is indexing my Angular.js app's content just fine, ie it executes the JS, XHRs, the whole deal, but for some reason the title is not indexed properly and remains the static HTML fallback (default title set by HTML, before JS is executed). Google很好地索引了我的Angular.js应用程序的内容,即它执行了JS,XHR,整个交易,但是由于某种原因,标题未正确索引,并保持静态HTML备用(由JS之前的HTML设置的默认标题)执行)。

In index.html I have: index.html我有:

<title ng-bind="title + ' &mdash; Default Title'">Default Title</title>

and it's set like this whenever the route changes: 并设置为每当路线更改时:

app.run ['$location', '$rootScope', ($location, $rootScope) ->
    $rootScope.$on '$routeChangeSuccess', (event, current, previous) ->
      $rootScope.title = current.$$route.title if current.$$route
]

Has anyone met with this problem yet and do you have a solution for it perhaps? 有人遇到过这个问题吗,也许您有解决方案?

For my angular site, I have this in my meta tag 对于我的有角网站,我在meta标签中有这个

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

This informs google that it is an ajax site and needs to recrawl my site differently. 这将告知Google这是一个Ajax网站,需​​要以其他方式重新抓取我的网站。 It will append _escaped_fragment_ at the end the url and recrawl. 它将在网址末尾附加_escaped_fragment_并重新抓取。 At that point, I return pure html with title tag. 那时,我返回带有标题标签的纯HTML。

Check out this link: https://developers.google.com/webmasters/ajax-crawling/docs/specification 查看此链接: https : //developers.google.com/webmasters/ajax-crawling/docs/specification

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

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