简体   繁体   English

由于站点映射和 seo,我应该从 react.js 将 swich 更改为 next.js

[英]should i change swich to next.js from react.js because of sitemaping and seo

i have created my react js app and have complted it and is hosted but i have faild with seo because my pages are not getting crawled and showing in google i saw some videos and every one is saying to use next js for something called server side rendering我已经创建了我的 react js 应用程序并完成了它并托管了它,但是我的 seo 失败了,因为我的页面没有被抓取并在谷歌中显示

will next.js solve my problem of google bot not crawling my website next.js 会解决我的 google bot 无法抓取我的网站的问题吗

my website is question and answersing just like stackoverflow so when ever i post a question a new url is generted我的网站就像 stackoverflow 一样问答,所以每当我发布问题时,都会生成一个新的 url

will this issue be solved by next js下个js会解决这个问题吗

this is how i am reading the urls in my react ap这就是我在我的反应应用程序中阅读网址的方式

<Link to={{pathname: `query/${itm._id}`,query: { id: itm._id },}} >
                <Alert className="question">
                  <h6>{itm.Name}</h6>
                </Alert>
</Link> 

i have used react-helmet also in my project我在我的项目中也使用过 react-helmet

 <Helmet>
                  <meta charSet="utf-8" />
                  <title> wixten - {itm.Name} </title>
                  <meta name="description" content={itm.Name} />
                  <meta property="og:type" content="article" />
                  <link rel="canonical" href={itm.Name} />
                </Helmet>

https://wixten.com/ https://wixten.com/

Next.js would definitely solve your problem. Next.js 绝对可以解决您的问题。

Check out Data Fetching page in the Next.js documentation.查看 Next.js 文档中的数据获取页面。 It explains the concept of Server Side Generation (SSG) and Server Side Rendering (SSR) very well.它很好地解释了服务器端生成(SSG)和服务器端渲染(SSR)的概念。 Either one should improve your SEO score greatly.任何一个都应该大大提高您的 SEO 分数。 I've done a similar refactoring in my app that renders a static data from a.js file using SSG method and I am pretty happy with the results in Google traffic.我在我的应用程序中进行了类似的重构,使用 SSG 方法从 a.js 文件呈现 static 数据,我对 Google 流量的结果非常满意。 (check it out if you'd like - ilmihal oku) (如果您愿意,请查看 - ilmihal oku)

To get an understanding of what a non-js aware web crawler will see in your site is to disable the Javascript for the browser tab.要了解非 js 感知 web 爬虫将在您的站点中看到的内容,请禁用浏览器选项卡的 Javascript。

在此处输入图像描述

It is empty as you are using client rendered React app.当您使用客户端呈现的 React 应用程序时,它是空的。 That means HTML is generated by the Javascript attached to index.html .这意味着HTML由附加到index.htmlJavascript生成。 Since you disabled Javascript nothing is added to the DOM .由于您禁用Javascript ,因此不会向DOM添加任何内容。

If you really check the index.html file it has nothing except the div with root as id ().如果你真的检查 index.html 文件,它除了以rootid () 的div之外什么都没有。

<div id="root"></div>

Solutions解决方案

  1. Google bots crawl Javascript as well. 谷歌机器人也会抓取 Javascript You can keep your client-rendered app as it is and rely on this type of crawling.您可以保持客户端呈现的应用程序原样并依赖这种类型的抓取。 But, you still need to submit a sitemap.xml for your site.但是,您仍然需要为您的站点提交一个sitemap.xml

  2. Create a simple express server that renders the HTML skeleton when it hits the server for the first time.创建一个简单的快速服务器,当 HTML 骨架第一次到达服务器时呈现它。 Basically, You can do it by accessing index.html in build folder and calling ReactDOMServer.renderToString(<YourReactAppRootComponent>) and send the HTML to the browser.基本上,您可以通过访问build文件夹中的index.html并调用ReactDOMServer.renderToString(<YourReactAppRootComponent>)并将HTML发送到浏览器来完成。 Now even though you have disabled the JS in the browser tab, you (or a web crawler) will see some content.现在,即使您在浏览器选项卡中禁用了 JS,您(或 web 爬虫)也会看到一些内容。 Check this article 检查这篇文章

  3. You can use migrate to a React framework like next.js or Gatasby to do SSR for you.您可以使用迁移到像next.jsGatasby这样的 React 框架来为您执行 SSR。

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

相关问题 React.js:警告:列表中的每个子项都应在 Next.js 中具有唯一的“键”道具 - React.js: Warning: Each child in a list should have a unique "key" prop in Next.js react.js(next.js) 中未应用 css 比例 - css scale is not applied in react.js(next.js) next.js 和 React.js 可以在没有 Webpack 的情况下工作吗? - Can next.js and React.js work without Webpack? 我无法在带有 Next.js 的 React.js 中使用状态变量中的 axios 填充请求响应 - I can't fill a request response using axios in state variable in React.js with Next.js React.js / Next.js - 如何从一篇文章链接到另一篇文章? - React.js / Next.js - how to link from one article to another? 当我刷新 react.js 和 next.js 页面时,它给了我 404 错误 - When I refresh the react.js and next.js page, it gives me 404 error 如何从我的代码 React.js/Next.js 制作一个钩子? - How to make a hook from my code React.js/Next.js? 如何从 next.js/react.js 中的 reactQuery/useQuery 中解构嵌套数据 - how to destructure nested data from reactQuery/useQuery in next.js/react.js 我可以使用'<component {…pageProps} /> ' 我通常在 React.js 的 Next.js 的 _app.js 中找到 - Can I use the '<Component {…pageProps} />' that I usually found in _app.js in Next.js for React.js 从 React/Next.js 中的 getInitalProps 重定向 - Redirecting from getInitalProps in React/Next.js
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM