我的 AngularJS 应用程序的 Google 索引 [英] Google indexing of my AngularJS application

查看:29
本文介绍了我的 AngularJS 应用程序的 Google 索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一篇来自 google 的博客文章,称他们正在为 javascript 应用程序编制索引.但是,我的 AngularJS 应用程序 www.fore-cite.com 似乎根本没有被索引.为了启用索引并使内容可搜索,我需要做什么特别的事情吗?

There was a blog post from google that they are indexing javascript applications. However, my AngularJS Application www.fore-cite.com seems not to be indexed at all. Is there anything special that I have to do in order to enable indexing and make the content searchable?

推荐答案

Google 抓取工具会在它抓取的页面上执行 javascript.使用 AngularJS,您必须采取一些步骤来确保您的应用程序被正确抓取和索引.

The Google crawler does execute javascript on the pages that it crawls. With AngularJS, there are a few steps you have to take to make sure that your application is getting crawled and indexed properly.

您必须使用 html5 模式.

为了使 html5 模式正常工作,您必须配置您的网络服务器,以便对不存在的目录的请求被重写到 index.html.

For the html5 mode to work properly, you must configure your webserver so that requests to directories that don't exist get rewritten to index.html.

Google 尚未正确跟踪 angularjs 应用中的链接,因此您必须为所有路线创建站点地图.这听起来很痛苦,但是,通过适当的构建过程,这可能是一个非常自动化的过程.(吞咽,咕噜声等)

Google does not properly follow links in angularjs apps yet, therefore you must create a sitemap for all of your routes. This sounds like a pain to do, however, with proper build processes this can be a very automated process. (gulp, grunt, etc.)

这当然只适用于谷歌爬虫.Bing 等其他搜索爬虫可能尚不支持 javascript 应用程序,但如果这种情况在未来一两年内发生变化(如果尚未发生变化),我不会感到惊讶.

This of course only applies to the google crawler. Other search crawlers such as Bing may not support javascript applications yet, though I wouldn't be surprised if this changes over the next year or two (if it hasn't already.)

索引 Angular 应用程序的一个常见问题是分页和单击按钮后显示的内容.如果这些操作不改变 url,google 就不会抓取它.例如,假设您有一个带有使用分页的表格的页面,它有 3 个页面.Google 只会抓取第一页,除非每个页面都有不同的 url 路由,例如 /table/page/1 /table/page/2 /table/page/3

One commonly missed problem with indexing angular apps is things like pagination and content that shows up after clicking a button. If these actions do not change the url, google will not crawl it. For example, say you have a page with a table using pagination and it has 3 pages. Google will only crawl the first page unless each page has a different url route such as /table/page/1 /table/page/2 /table/page/3

这篇关于我的 AngularJS 应用程序的 Google 索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆