Re: [问题] 想请问 SPA/Ajax 对 SEO 的影响

楼主: DarkKnightX (Why so serious?)   2017-05-13 06:07:20
※ 引述《GitLab (GitLab)》之铭言:
: 大家好
: 想问一下 SPA (Single Page Application) 的架构下
: 对网页的内容都是透过 Ajax 来实现以及 History 来更换网址
: 由于内容都必须等待 Ajax 后才会 Render
: 这样的话是否会影响 Google, Yahoo, Bing 的 Robot 来爬资料?
: 机器人应该只单纯爬 HTML 结构而已?
: 就我的观念机器人爬到的网页内容应该只有还没 Call Ajax 前的内容
现在已经不是这样了, 至少 Google 的 bot 懂 js 和 css: https://goo.gl/b50u4u
另外 Yahoo 和 Bing 搜寻结果也都有 run 过 js 才有的内容: https://goo.gl/UizXTL
应该只剩百度不懂 js?
: 想请问现代 JS 框架中(React or Angular) 是否已经可以解决这类问题
在搜寻引擎的 bot 开放 js 之前, 解决方法是 server side rendering:
https://goo.gl/Ows74u
简单来说就是在 server 上执行原本在 browser 用的 js, 产生第一个画面的 HTML,
传到 browser (或是 bot) 之后再回到原本的方法.
React 用 react-dom: https://facebook.github.io/react/docs/react-dom-server.html
Angular 用 Angular Universal: https://universal.angular.io/
现在搜寻引擎也懂 js 了, 做 SSR 是为了先给 user 一些东西看,
避免在第一个画面之前空很久.

Links booklink

Contact Us: admin [ a t ] ucptt.com