为什么在使用Next.js时,视图源代码与WordPress不对齐?

huangapple go评论58阅读模式
英文:

Why with nextjs view source is not aligned, like in wordpress

问题

如果视图源代码像在NextJS项目中那样混乱,可能会对SEO产生不利影响,因为搜索引擎机器人可能会难以理解和分析页面内容。优化网站以使HTML源代码更干净和有序通常是一个良好的做法,有助于搜索引擎更好地理解和索引您的页面。

在WordPress等CMS中,HTML通常会更结构化和清晰,这有助于搜索引擎更轻松地识别关键内容。如果您使用NextJS或其他框架,确保生成的HTML尽可能干净,并遵循SEO最佳实践,如使用语义化的HTML标记和适当的meta标签。这将有助于确保搜索引擎可以有效地理解和排名您的网站内容。

英文:

I am new in NextJS and I want to learn it because I want to build websites to be recognized by google search engine, so to have a good SEO. WordPress is very good in this direction, because outputs in view source the html for website.

I looked on view source for NextJS project and looks like this:

<!DOCTYPE html><html><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"/><meta name="next-head-count" content="2"/><link rel="preload" href="/_next/static/development/pages/index.js?ts=1578323131691" as="script"/><link rel="preload" href="/_next/static/development/pages/_app.js?ts=1578323131691" as="script"/><link rel="preload" href="/_next/static/runtime/webpack.js?ts=1578323131691" as="script"/><link rel="preload" href="/_next/static/runtime/main.js?ts=1578323131691" as="script"/></head><body><div id="__next"><h1>Welcome to NextJS</h1></div><script src="/_next/static/development/dll/dll_d6a88dbe3071bd165157.js?ts=1578323131691"></script><script id="__NEXT_DATA__" type="application/json">{"dataManager":"[]","props":{"pageProps":{}},"page":"/","query":{},"buildId":"development","nextExport":true,"autoExport":true}</script><script nomodule="" src="/_next/static/runtime/polyfills.js?ts=1578323131691"></script><script async="" data-next-page="/" src="/_next/static/development/pages/index.js?ts=1578323131691"></script><script async="" data-next-page="/_app" src="/_next/static/development/pages/_app.js?ts=1578323131691"></script><script src="/_next/static/runtime/webpack.js?ts=1578323131691" async=""></script><script src="/_next/static/runtime/main.js?ts=1578323131691" async=""></script></body></html>

then I remembered that in the wordpress websites, the view source was nicely aligned:

<body
  class="home page-template page-template-tpl-fullwidth page-template-tpl-fullwidth-php page page-id-7 page-parent mltlngg-ro_RO elementor-default">
  <!-- **Wrapper** -->
  <div class="wrapper">
    <!-- **Inner Wrapper** -->
    <div class="inner-wrapper">

      <div id="bbar-wrapper" class="type1">
        <div id="bbar-body">
          <div class="container">
            <div class="column dt-sc-one-half first">
              <p class="bbar-text"></p>
            </div>
            <div class="column dt-sc-one-half alignright">
              <div class="mltlngg_switcher">
                <form name="mltlngg_change_language" method="post" action=""><button name="mltlngg_change_display_lang"
                    value="ro_RO">
                    <img src=""
                      alt="Română">
                  </button><button name="mltlngg_change_display_lang" value="en_GB">
                    <img src="g"
                      alt="English">
                  </button></form>
              </div>
              <div><span class="fa fa-phone-square"> </span> <a href="tel:" class="phone_call"></a><a href="mailto:" title="Trimite Email"> 
                </a></div>
            </div>
          </div>
        </div>
        <span class="bbar-divider"></span>
      </div>
      <!-- Header Wrapper -->
      <div id="header-wrapper">

        <!-- **Header** -->
        <header id="header" class="header1 gradient-bg">

          <!-- **Header Container** -->
          <div class="container">
            <!-- **Logo - End** -->
            <div id="logo">

              

My question is: if the view source code is a mess, like in the NextJS project, this will not make google search engine robots to be confused? So this will not have a bad impact on SEO?

答案1

得分: 2

下一个输出的源代码已被缩小(=下载所需的字节数较少)。

Google bot及其他机器人不会像人类一样读取该源代码,而是将其解析为易于遍历的内容(AST)。

如果输出是有效的HTML,解析器将能够毫无问题地解析它。

英文:

The source code of next out is minified (= takes less bytes to download).

Google bot & other bots not reads that source code as humans, but parses it into something that will be easy to traversal (AST).

If the output is VALID html, the parser will be able to parse it without any problem.

答案2

得分: 0

不必担心源代码的对齐。
NextJs网页具有被压缩的源代码(即整个源代码显示在一行中)。

压缩的源代码对于搜索引擎优化机器人来说非常容易抓取。

英文:

Don't worry with the alignment of the source code.
NextJs webpage has minified source code(i.e., the entire source code is displayed in one single line)

Minified source code is very easy for SEO bots to crawl.

huangapple
  • 本文由 发表于 2020年1月6日 23:20:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/59614619.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定