简体   繁体   English

预渲染 Vue? Nuxt.js 或插件,现有网站哪个更好

[英]Prerendering Vue? Nuxt.js or plugin, what is better for existing website

I have webiste which is available in the internet.我有网站,可以在互联网上找到。 Front is written in Vue.js and CMS is created using Laravel (PHP). Front 使用 Vue.js 编写,CMS 使用 Laravel (PHP) 创建。 These are separate applications.这些是单独的应用程序。 Unfortunatelly Google dosen't see the page because of lack of SEO (yeah. Vue), The website is big, has a lot of routes.不幸的是,由于缺乏 SEO(是的。Vue),谷歌没有看到该页面,该网站很大,有很多路线。 fetches data from API ex.从 API 前获取数据。 for a blog.一个博客。 Here is my question?这是我的问题? What is a better solution?什么是更好的解决方案? Move website to Nuxt.js or use some fancy plugin like https://github.com/chrisvfritz/prerender-spa-plugin and fetch data from API.将网站移动到 Nuxt.js 或使用一些花哨的插件,如https://github.com/chrisvfritz/prerender-spa-plugin并从 API 获取数据。 I'll be gratefull for any tips!我将不胜感激任何提示!

Use @prerenderer/renderer-puppeteer if: You're prerendering up to a couple hundred pages and want accurate results.在以下情况下使用@prerenderer/renderer-puppeteer :您要预渲染多达几百页并想要准确的结果。

Use @prerenderer/renderer-jsdom if: You need to prerender thousands upon thousands of pages, but quality isn't all that important, and you're willing to work around issues for more advanced cases.在以下情况下使用@prerenderer/renderer-jsdom :您需要预渲染成千上万的页面,但质量并不是那么重要,并且您愿意为更高级的案例解决问题。 (Programmatic SVG support, etc.) (可编程SVG支持等)

Let me try to put my two cents here.让我试着把我的两分钱放在这里。 As far as I know, here are two ways to rendering statically on your server using vue.据我所知,这里有两种使用 vue 在服务器上静态渲染的方法。

  1. SSR (Server Side Rendering) - (I haven't implemented it) What happens is that when you call a certain route the HTML dom content is loaded and set to the page before loading and then loads the page with the HTML content on the fly, this prevents the blanks pages sent to google crawlers (As far as I know). SSR(服务器端渲染)-(我还没有实现)发生的情况是,当您调用某个路由时,会加载 HTML dom 内容并在加载前设置为页面,然后动态加载带有 HTML 内容的页面,这可以防止将空白页面发送给谷歌爬虫(据我所知)。 You are basically showing basic html, css and js now.您现在基本上是在展示基本的 html、css 和 js。 This will use a lot of server CPU for processing every route request that comes to the server, so you have to make sure that the project you are developing doesn't have so much traffic that your server overloads.这将使用大量服务器 CPU 来处理到达服务器的每个路由请求,因此您必须确保您正在开发的项目没有太多流量而导致服务器过载。
  2. Prerendering - In this, the server prebuilds the HTML pages for each and every route in your site.预渲染 - 在此,服务器为您站点中的每个路由预构建 HTML 页面。 Also you have to specify the routes that are needed to be rendered manually or you have to find a way to pass the dynamic array to build it all the time.此外,您必须指定需要手动渲染的路线,或者您必须找到一种方法来传递动态数组以始终构建它。 Since the generation of the files needs a building of the new HTML files with new content you need to implement a system to run the build each time you have to add a new route or a do some updates on the existing pages.由于文件的生成需要使用新内容构建新的 HTML 文件,因此每次必须添加新路线或在现有页面上进行一些更新时,您都需要实现一个系统来运行构建。 You should try CI/CD for this for automated processes.您应该为此尝试 CI/CD 以实现自动化流程。 I haven't implemented it but it might get a little bit hectic.我还没有实现它,但它可能会有点忙。

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

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