[英]Do I need a separate page for each piece of content with AngularJS?
Background: I am working on creating a stock-market application that would contain company description, history, industry, share price, etc. and will allow users to add new companies at their will.背景:我正在创建一个股票市场应用程序,该应用程序将包含公司描述、历史、行业、股价等,并允许用户随意添加新公司。 When the user wants to read about a specific company, he/she simply enters the ticker into the search box, and the page is updated with the content for that company.
当用户想要阅读有关特定公司的信息时,他/她只需在搜索框中输入股票代码,页面就会更新为该公司的内容。 I am planning on using MySQL database to store static content information such as description, PHP as a server-side language, APIs for dynamic data (eg stock prices), and AngularJS for front-end development, particularly to eliminate constant page-reloading and speed up the development cycle.
我计划使用 MySQL 数据库来存储静态内容信息,例如描述、PHP 作为服务器端语言、用于动态数据的 API(例如股票价格)和用于前端开发的 AngularJS,特别是为了消除不断的页面重新加载和加快开发周期。
Question 1 (1 company = 1 page?): Initially, I was contemplating creating AJAX requests via $http and then simply populating the html template with the {{content}} generated by that request, but then I heard that creating a separate page for each piece of content is also a common method and is preferred for SEO (essentially, the URLs would look like that: www.mysite.com/#/main/page vs www.mysite.com/main/page/company1.php for the first and second methods respectively).问题 1(1 家公司 = 1 页?):最初,我正在考虑通过$http创建 AJAX 请求,然后简单地使用该请求生成的{{content}}填充 html 模板,但后来我听说创建一个单独的页面对于每条内容也是一种常用方法,并且是 SEO 的首选(基本上,URL 看起来像这样: www.mysite.com/#/ main / page vs www.mysite.com/main/page/company1.php分别为第一种和第二种方法)。 Which method is indeed a preferred one or what is the best practice if none of those methods are correct in this situation?
哪种方法确实是首选方法,或者如果在这种情况下这些方法都不正确,最佳做法是什么?
Question 2 (SEO/Sitemap): Now if I stick to the first method ($http), I realize search engine crawlers will have difficulty identifying the pages, because, technically, there aren't any pages with content;问题 2(SEO/Sitemap):现在如果我坚持第一种方法($http),我意识到搜索引擎爬虫很难识别页面,因为从技术上讲,没有任何页面有内容; they are all generated dynamically.
它们都是动态生成的。 Is this true that the search engines won't find my pages, and if so, is there a way around this issue?
搜索引擎找不到我的页面是真的吗?如果是,有没有办法解决这个问题?
Thanks so much!非常感谢!
With Angular you can easily have a unique URL for each piece of content.使用 Angular,您可以轻松地为每条内容拥有一个唯一的 URL。 To achieve this, you can use the router (cf. https://docs.angularjs.org/api/ngRoute or https://angular.github.io/router/getting-started ).
为此,您可以使用路由器(参见https://docs.angularjs.org/api/ngRoute或https://angular.github.io/router/getting-started )。 It allows your application to:
它允许您的应用程序:
Thus, your users will be able to share links, bookmark contents, ...因此,您的用户将能够共享链接、书签内容、...
For bots, you will need to serve HTML snapshots.对于机器人,您需要提供 HTML 快照。 It can be done using a service like SEO4Ajax .
可以使用SEO4Ajax 之类的服务来完成。 Alternatively, if you want to do it yourself, there is an excellent tutorial here .
另外,如果你想自己做,有一个优秀的教程在这里。
Google can index javascript websites (annouced by Google May 2014), but Google may not properly render or index angular websites. Google 可以为 javascript 网站编制索引(由 Google 于 2014 年 5 月宣布),但 Google 可能无法正确呈现或索引有角度的网站。 Technical SEO expertise is needed to ensure that you have an SEO friendly site architecture including page title, meta tags, h1, etc, targeting the right keywords.
需要技术 SEO 专业知识来确保您拥有 SEO 友好的站点架构,包括页面标题、元标记、h1 等,针对正确的关键字。 Developers may find their site is only partially rendered and indexed, or not at all.
开发人员可能会发现他们的网站只是部分呈现和索引,或者根本没有。
You can take measures such as using $locationProvider.html5Mode(true);
您可以采取措施,例如使用
$locationProvider.html5Mode(true);
to remove AngularJS's default hashtagged-URLs.删除 AngularJS 的默认 hashtagged-URL。
It is also commonly accepted that serving a rendered version of the angular website to crawlers is required to achieve good search performance.人们还普遍认为,需要向爬虫提供角度网站的渲染版本才能实现良好的搜索性能。 (One of such services is Prerender.io).
(其中一种服务是 Prerender.io)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.