简体   繁体   中英

SEO and crawling: UI-Router ui-sref VS ng-click

After looking around a bit I came to no conclusion about this matter: does Google and other search engines crawl pages that are only accessible through ng-click, without an anchor tag? Or does an anchor tag always need to be present for the crawling to work successfully?

I have to build various elements which link to other pages in a generic way and ng-click is the best solution for me in terms of flexibility, but I suppose Google won't "click" those elements since they have no anchor tag.

Besides the obvious ui-sref tag with I have about other solutions like:

<a ng-click = 'controller.changeToLink()'>Link name</a>

Altough I am not sure if this is a good practice either.

Can someone please clarify this issue for me? Thanks.

Single page applications are in general very SEO unfriendly, ng-click not being followed being the least of the problems.

The application does not get rendered server side, so search engine crawlers have a hard time properly indexing the content.

According to this latest recommendation , the Google crawler can render and index most dynamic content.

The way that it will work is that it will wait for the Javascript to kicking and render the application, and only index after the content is injected in the page. This process is not 100% proof and single page applications cannot compete with static applications until recently.

This is the main reason why most sites are using them for their menu system, as that would make for a much better user experience than full page reloads. Single page apps are not SEO friendly.

This is slowly changing as now Angular Universal, Ember Fast Boot and React are adding the possibility to render server side an SEO friendly page, but still have it take over as SPA on the client side.

I think your best bet to try to improve your SEO is to submit a site map file to google using their webmaster tools. This will let google know about those pages that you trigger via ng-click.

Note that this only has a chance of working if you are using the HTML5 mode for the router and not using bookmarks (urls using #), as Google does not index bookmarks.

In general its very hard to get good SEO for an Angular 1 app, and thats why its mostly not used for public indexable content. The sweetspot of AngularJs is for building the "dashboard" private section of your app, that users can access after logging in.

尝试使用prerender.io来预渲染这些angularge页面,并过滤出漫游器请求并从页面缓存中提供这些预渲染的页面。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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