[英]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>
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.html
的Javascript
生成。 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 文件,它除了以
root
为id
() 的div
之外什么都没有。
<div id="root"></div>
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
。
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
检查这篇文章
You can use migrate to a React framework like next.js
or Gatasby
to do SSR for you.您可以使用迁移到像
next.js
或Gatasby
这样的 React 框架来为您执行 SSR。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.