{"id":7461,"date":"2024-04-03T16:01:01","date_gmt":"2024-04-03T08:01:01","guid":{"rendered":""},"modified":"2024-04-03T16:01:01","modified_gmt":"2024-04-03T08:01:01","slug":"vue\u9879\u76eeSEO\u4e0d\u53cb\u597d\u600e\u4e48\u529e\uff1f","status":"publish","type":"post","link":"https:\/\/mushiming.com\/7461.html","title":{"rendered":"vue\u9879\u76eeSEO\u4e0d\u53cb\u597d\u600e\u4e48\u529e\uff1f"},"content":{"rendered":"

\n <\/path> \n<\/svg> <\/p>\n

\u89e3\u51b3vue\u9879\u76eeSEO\u4e0d\u53cb\u597d\u7684\u95ee\u9898<\/h2>\n

\u9996\u5148\u4e86\u89e3\u4ec0\u4e48\u662fSEO\uff1f<\/h5>\n
\n

SEO\u662f\u7531\u82f1\u6587Search Engine Optimization\u7f29\u5199\u800c\u6765\uff0c \u4e2d\u6587\u610f\u8bd1\u4e3a\u201c\u641c\u7d22\u5f15\u64ce\u4f18\u5316\u201d\u3002<\/p>\n

SEO\u662f\u6307\u901a\u8fc7\u7ad9\u5185\u4f18\u5316\u6bd4\u5982\u7f51\u7ad9\u7ed3\u6784\u8c03\u6574\u3001\u7f51\u7ad9\u5185\u5bb9\u5efa\u8bbe\u3001\u7f51\u7ad9\u4ee3\u7801\u4f18\u5316\u7b49\u53ca\u7ad9\u5916\u4f18\u5316\uff0c\u6bd4\u5982\u7f51\u7ad9\u7ad9\u5916\u63a8\u5e7f\u3001\u7f51\u7ad9\u54c1\u724c\u5efa\u8bbe\u7b49\uff0c\u4f7f\u7f51\u7ad9\u6ee1\u8db3\u641c\u7d22\u5f15\u64ce\u6536\u5f55\u6392\u540d\u9700\u6c42\uff0c\u5728\u641c\u7d22\u5f15\u64ce\u4e2d\u63d0\u9ad8\u5173\u952e\u8bcd\u6392\u540d\uff0c\u4ece\u800c\u628a\u7cbe\u51c6\u7528\u6237\u5e26\u5230\u7f51\u7ad9\uff0c\u83b7\u5f97\u514d\u8d39\u6d41\u91cf\uff0c\u4ea7\u751f\u76f4\u63a5\u9500\u552e\u6216\u54c1\u724c\u63a8\u5e7f\u3002<\/p>\n<\/blockquote>\n

SEO\u4e3b\u8981\u4f18\u5316\u54ea\u4e9b\u5185\u5bb9\uff1f<\/strong><\/h5>\n

\u5185\u90e8\u4f18\u5316<\/strong><\/p>\n

    \n
  • \n

    META\u6807\u7b7e\u4f18\u5316\uff1a\u4f8b\u5982\uff1aTITLE<\/code>\uff0cKEYWORDS<\/code>\uff0cDESCRIPTION<\/code>\u7b49\u7684\u4f18\u5316<\/p>\n<\/li>\n

  • \n

    \u5185\u90e8\u94fe\u63a5\u7684\u4f18\u5316\uff0c\u5305\u62ec\u76f8\u5173\u6027\u94fe\u63a5(Tag\u6807\u7b7e)\uff0c\u951a\u6587\u672c\u94fe\u63a5\uff0c\u5404\u5bfc\u822a\u94fe\u63a5\uff0c\u53ca\u56fe\u7247\u94fe\u63a5<\/p>\n<\/li>\n

  • \n

    \u7f51\u7ad9\u5185\u5bb9\u66f4\u65b0\uff1a\u6bcf\u5929\u4fdd\u6301\u7ad9\u5185\u7684\u66f4\u65b0(\u4e3b\u8981\u662f\u6587\u7ae0\u7684\u66f4\u65b0\u7b49)<\/p>\n<\/li>\n<\/ul>\n

    \u5916\u90e8\u4f18\u5316<\/strong><\/p>\n

      \n
    • \n

      \u5916\u90e8\u94fe\u63a5\u7c7b\u522b\uff1a\u535a\u5ba2\u3001\u8bba\u575b\u3001B2B\u3001\u65b0\u95fb\u3001\u5206\u7c7b\u4fe1\u606f\u3001\u8d34\u5427\u3001\u95ee\u7b54\u3001\u767e\u79d1\u3001\u793e\u533a\u3001\u7a7a\u95f4\u3001\u5fae\u4fe1\u3001\u5fae\u535a\u7b49\u76f8\u5173\u4fe1\u606f\u7f51\u7b49\u5c3d\u91cf\u4fdd\u6301\u94fe\u63a5\u7684\u591a\u6837\u6027\u3002<\/p>\n<\/li>\n

    • \n

      \u5916\u94fe\u7ec4\u5efa\uff1a\u6bcf\u5929\u6dfb\u52a0\u4e00\u5b9a\u6570\u91cf\u7684\u5916\u90e8\u94fe\u63a5\uff0c\u4f7f\u5173\u952e\u8bcd\u6392\u540d\u7a33\u5b9a\u63d0\u5347\u3002<\/p>\n<\/li>\n

    • \n

      \u53cb\u94fe\u4e92\u6362\uff1a\u4e0e\u4e00\u4e9b\u548c\u4f60\u7f51\u7ad9\u76f8\u5173\u6027\u6bd4\u8f83\u9ad8,\u6574\u4f53\u8d28\u91cf\u6bd4\u8f83\u597d\u7684\u7f51\u7ad9\u4ea4\u6362\u53cb\u60c5\u94fe\u63a5,\u5de9\u56fa\u7a33\u5b9a\u5173\u952e\u8bcd\u6392\u540d\u3002<\/p>\n<\/li>\n<\/ul>\n

      \u5f15\u64ce\u8718\u86db\u7684\u5de5\u4f5c\u539f\u7406\uff1f<\/h5>\n

      \u7f51\u7edc\u722c\u866b\u5728\u722c\u53d6\u7f51\u9875\u5185\u5bb9\u7684\u65f6\u5019\uff0c\u9700\u8981\u5206\u6790\u9875\u9762\u5185\u5bb9\uff0c\u4e3b\u8981\u6709\u4ee5\u4e0b\u51e0\u70b9\uff1a<\/p>\n

        \n
      • \n

        \u4ece meta \u6807\u7b7e\u4e2d\u8bfb\u53d6 keywords<\/code> \u3001 description<\/code> \u7684\u5185\u5bb9\u3002<\/p>\n<\/li>\n

      • \n

        \u6839\u636e\u8bed\u4e49\u5316\u7684 html<\/code> \u7684\u6807\u7b7e\u722c\u53d6\u548c\u5206\u6790\u5185\u5bb9\u3002\u4e00\u4e2a\u6574\u4f53\u90fd\u662f\u7528 div \u6807\u7b7e\u7684\u7f51\u7ad9\u548c\u6b63\u786e\u4f7f\u7528\u4e86 html5<\/code> \u6807\u7b7e\u7684\u6548\u679c\u662f\u4e0d\u4e00\u6837\u7684\u3002<\/p>\n<\/li>\n

      • \n

        \u8bfb\u53d6 a<\/code> \u6807\u7b7e\u91cc\u7684\u94fe\u63a5\uff0c\u901a\u8fc7 a<\/code> \u6807\u7b7e\u7684\u94fe\u63a5\u53ef\u4ee5\u8df3\u8f6c\u5230\u522b\u7684\u7f51\u7ad9\u3002\uff08\u722c\u866b\u662f\u5148\u8df3\u8f6c\uff0c\u8fd8\u662f\u7ee7\u7eed\u722c\u5185\u5bb9\u518d\u8df3\u8f6c\uff0c\u5c31\u770b\u7b97\u6cd5\u662f\u5e7f\u5ea6\u4f18\u5148\u8fd8\u662f\u6df1\u5ea6\u4f18\u5148\u4e86\uff09<\/p>\n<\/li>\n

      • \n

        \u50cf h1 - h6<\/code> \u6807\u7b7e\u662f\u5177\u6709\u4e0d\u540c\u7a0b\u5ea6\u7684\u5f3a\u8c03\u610f\u4e49\u7684\u3002<\/p>\n<\/li>\n

      • \n

        \u4e00\u822c\u5c06 h1<\/code> \u89c6\u4e3a\u91cd\u8981\u5185\u5bb9\u3002\u540c\u6837\u6709\u5f3a\u8c03\u5185\u5bb9\u8fd8\u6709 strong<\/code> \u3001 em<\/code> \u6807\u7b7e\u3002<\/p>\n<\/li>\n<\/ul>\n

        SEO<\/code>\u4e3a\u5565\u5bf9vue<\/code>\u5355\u9875\u9762\u4e0d\u53cb\u597d?<\/h5>\n
          \n
        1. \n

          vue<\/code>\u7528js<\/code>\u6765\u6e32\u67d3\u6570\u636e\u5bf9SEO<\/code>\u4e0d\u53cb\u597d<\/p>\n

          \u641c\u7d22\u5f15\u64ce\u7684\u57fa\u7840\u722c\u866b\u7684\u539f\u7406\u5c31\u662f\u6293\u53d6\u4f60\u7684url<\/code>\uff0c\u7136\u540e\u83b7\u53d6\u4f60\u7684html<\/code>\u6e90\u4ee3\u7801\u5e76\u89e3\u6790\u3002 \u800cvue<\/code>\u9879\u76ee\u662f\u91c7\u7528js<\/code>\u7684\u6570\u636e\u7ed1\u5b9a\u673a\u5236\u6765\u5c55\u73b0\u9875\u9762\u6570\u636e\u7684\uff0c\u722c\u866b\u83b7\u53d6\u5230\u7684html<\/code>\u662f\u4f60\u7684\u6a21\u578b\u9875\u9762\u800c\u4e0d\u662f\u6700\u7ec8\u6570\u636e\u7684\u6e32\u67d3\u9875\u9762\uff0c\u6240\u4ee5\u8bf4\u7528**js<\/code>\u6765\u6e32\u67d3\u6570\u636e\u5bf9seo<\/code>\u5e76\u4e0d\u53cb\u597d**\u3002<\/p>\n<\/li>\n

        2. \n

          vue<\/code>\u5355\u9875\u9875\u9762\u5bf9SEO<\/code>\u4e0d\u53cb\u597d<\/p>\n

          seo<\/code> \u672c\u8d28\u662f\u4e00\u4e2a\u670d\u52a1\u5668\u5411\u53e6\u4e00\u4e2a\u670d\u52a1\u5668\u53d1\u8d77\u8bf7\u6c42\uff0c\u89e3\u6790\u8bf7\u6c42\u5185\u5bb9\u3002\u4f46\u4e00\u822c\u6765\u8bf4\u641c\u7d22\u5f15\u64ce\u662f\u4e0d\u4f1a\u53bb\u6267\u884c\u8bf7\u6c42\u5230\u7684js<\/code>\u7684\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u5982\u679c\u4e00\u4e2a\u5355\u9875\u5e94\u7528\uff0chtml<\/code>\u5728\u670d\u52a1\u5668\u7aef\u6ca1\u6709\u6e32\u67d3\u6570\u636e\uff0c\u5728\u6d4f\u89c8\u5668\u624d\u6e32\u67d3\u51fa\u6570\u636e\u7684\uff0c\u800c\u641c\u7d22\u5f15\u64ce\u8bf7\u6c42\u5230\u7684html<\/code>\u662f\u6ca1\u6709\u6e32\u67d3\u6570\u636e\u7684\u3002 \u8fd9\u6837\u5c31\u5f88\u4e0d\u5229\u4e8e\u5185\u5bb9\u88ab\u641c\u7d22\u5f15\u64ce\u641c\u7d22\u5230\uff0c \u6240\u4ee5\u670d\u52a1\u7aef\u6e32\u67d3\u5c31\u662f\u5c3d\u91cf\u5728\u670d\u52a1\u5668\u53d1\u9001\u5230\u6d4f\u89c8\u5668\u524d\u9875\u9762\u4e0a\u5c31\u662f\u6709\u6570\u636e\u7684<\/strong>\u3002<\/p>\n<\/li>\n<\/ol>\n

          \u89e3\u51b3\u65b9\u6848<\/h5>\n

          \u76ee\u524d\u4e86\u89e3\u5230\u4e24\u79cd\u89e3\u51b3\u65b9\u6848\uff1a<\/p>\n

          1.\u670d\u52a1\u7aef\u6e32\u67d3\uff0cVue<\/code>\u7684SSR<\/code>\u6e32\u67d3(\u914d\u7f6e\u53c2\u8003)\uff0cSSR\u6bd4\u8f83\u590d\u6742\u3002<\/p>\n

          2.\u9875\u9762\u9884\u6e32\u67d3\uff0cprerender-spa-plugin<\/code>\u63d2\u4ef6\u5b9e\u73b0(\u914d\u7f6e\u53c2\u8003)<\/p>\n

          \u7b2c\u4e00\u79cd\u670d\u52a1\u7aef\u6e32\u67d3\u53ef\u4ee5\u53c2\u8003Vue<\/code>\u5b98\u65b9\u6587\u6863\u4e2dSSR<\/code>\u670d\u52a1\u7aef\u6e32\u67d3\uff0c\u5bf9Vue<\/code>\u7248\u672c\u6709\u8981\u6c42\uff0c\u5bf9\u670d\u52a1\u5668\u4e5f\u6709\u4e00\u5b9a\u8981\u6c42\uff0c\u9700\u8981\u652f\u6301nodejs<\/code>\u73af\u5883\u3002<\/p>\n

          \u8fd9\u91cc\u4e3b\u8981\u4ecb\u7ecd\u4e00\u4e0b\u4f7f\u7528prerender-spa-plugin<\/code>\u9875\u9762\u9884\u6e32\u67d3\u7684\u65b9\u6cd5\uff1a<\/p>\n

          \n

          \u539f\u7406\uff1a\u5229\u7528\u5e93 prerender-spa-plugin<\/code> + vue-meta-info<\/code> \u914d\u7f6ewebpack<\/code>\u548c\u9875\u9762\u5b9e\u73b0\u9884\u6e32\u67d3\u65b9\u6848\uff0c\u6700\u7ec8build\u51fa\u6765\u591a\u4e2ahtml<\/code>\u6587\u4ef6<\/p>\n<\/blockquote>\n

            \n
          1. \n

            \u9996\u5148\u9700\u8981\u5b89\u88c5prerender-spa-plugin<\/code>\u548cvue-meta-info<\/code><\/p>\n

            npm<\/span> install<\/span> --save prerender-spa-plugin\nnpm<\/span> install<\/span> --save vue-meta-info\n<\/code><\/pre>\n

            prerender-spa-plugin<\/code>\u89e3\u51b3\u6253\u5305\u591a\u4e2a\u9875\u9762<\/p>\n

            vue-meta-info<\/code>\u89e3\u51b3SEO<\/code>\u7684\u95ee\u9898<\/p>\n<\/li>\n

          2. \n

            \u5728\u9879\u76ee\u4e2d\u627e\u5230main.js<\/code>,\u914d\u7f6e\u4ee5\u4e0b\u4ee3\u7801<\/p>\n

            import<\/span> Vue from<\/span> 'vue'<\/span>\nimport<\/span> MetaInfo from<\/span> 'vue-meta-info'<\/span>\nVue.<\/span>use<\/span>(<\/span>MetaInfo)<\/span>\nnew<\/span> Vue<\/span>(<\/span>{ \n     <\/span>\n  router,<\/span>\n  render<\/span>:<\/span> h<\/span> =><\/span> h<\/span>(<\/span>App)<\/span>,<\/span>\n  mounted<\/span> (<\/span>)<\/span> { \n     <\/span>\n    document.<\/span>dispatchEvent<\/span>(<\/span>new<\/span> Event<\/span>(<\/span>'render-event'<\/span>)<\/span>)<\/span>\n  }<\/span>\n}<\/span>)<\/span>.<\/span>$mount<\/span>(<\/span>'#app'<\/span>)<\/span>\n<\/code><\/pre>\n<\/li>\n
          3. \n

            \u914d\u7f6ewebpack<\/code><\/p>\n

            const<\/span> path =<\/span> require<\/span>(<\/span>'path'<\/span>)<\/span>\nconst<\/span> PrerenderSPAPlugin =<\/span> require<\/span>(<\/span>'prerender-spa-plugin'<\/span>)<\/span>;<\/span>\nconst<\/span> Renderer =<\/span> PrerenderSPAPlugin.<\/span>PuppeteerRenderer;<\/span>\nmodule.<\/span>exports =<\/span> { \n     <\/span>\n  new<\/span> PrerenderSPAPlugin<\/span>(<\/span>{ \n     <\/span>\n    \/\/ \u5fc5\u9700 - \u8981\u9884\u6e32\u67d3\u7684 webpack \u8f93\u51fa\u5e94\u7528\u7a0b\u5e8f\u7684\u8def\u5f84<\/span>\n    staticDir<\/span>:<\/span> path.<\/span>join<\/span>(<\/span>__dirname,<\/span> '\/dist'<\/span>)<\/span>,<\/span>\n    \/\/ \u5fc5\u9700 - \u8981\u6e32\u67d3\u7684\u8def\u7531\u3002<\/span>\n    routes<\/span>:<\/span> [<\/span>\n      '\/index'<\/span>,<\/span>\n      '\/home'<\/span>,<\/span>\n      '\/login'<\/span>,<\/span>\n    ]<\/span>,<\/span>\n    \/\/ \u9884\u6e32\u67d3\u4ee3\u7406\u63a5\u53e3<\/span>\n    \/\/ server: { \n     <\/span>\n    \/\/ proxy: { \n     <\/span>\n    \/\/ '\/api': { \n     <\/span>\n    \/\/ target: 'http:\/\/localhost:9001',<\/span>\n    \/\/ secure: false<\/span>\n    \/\/ }<\/span>\n    \/\/ }<\/span>\n    \/\/ },<\/span>\n    \/\/ \u6e32\u67d3\u5668<\/span>\n    renderer<\/span>:<\/span> new<\/span> Renderer<\/span>(<\/span>{ \n     <\/span>\n      \/\/ \u53ef\u9009 - \u8981\u6dfb\u52a0\u5230\u5305\u542b `inject` \u5185\u5bb9\u7684 window \u5bf9\u8c61\u7684\u5c5e\u6027\u540d\u79f0\u3002<\/span>\n      injectProperty<\/span>:<\/span> '__PRERENDER_INJECTED'<\/span>,<\/span>\n      \/\/ \u53ef\u9009 - \u60a8\u5e0c\u671b\u60a8\u7684\u5e94\u7528\u7a0b\u5e8f\u53ef\u4ee5\u901a\u8fc7 `window.injectProperty` \u8bbf\u95ee\u7684\u4efb\u4f55\u503c\u3002<\/span>\n      inject<\/span>:<\/span> { \n     <\/span>\n        foo<\/span>:<\/span> 'bar'<\/span>\n      }<\/span>,<\/span>\n      headless<\/span>:<\/span> true<\/span>,<\/span> \/\/ \u6e32\u67d3\u65f6\u663e\u793a\u6d4f\u89c8\u5668\u7a97\u53e3\u3002\u7528\u4e8e\u8c03\u8bd5<\/span>\n      renderAfterDocumentEvent<\/span>:<\/span> 'render-event'<\/span> \/\/ \u5bf9\u5e94main.js\u4e2d\u7684\u4e8b\u4ef6\u540d<\/span>\n    }<\/span>)<\/span>\n  }<\/span>)<\/span>,<\/span>\n}<\/span>\n<\/code><\/pre>\n<\/li>\n
          4. \n

            \u5c06\u9700\u8981\u9884\u6e32\u67d3\u7684\u9875\u9762\u914d\u7f6eSEO<\/code>\u6587\u5b57\u5185\u5bb9\uff08\u5bf9\u5e94\u4e0a\u9762routes\u6570\u7ec4\u91cc\u8def\u7531\u6307\u5411\u7684\u9875\u9762\uff09<\/p>\n

            export<\/span> default<\/span> { \n     <\/span>\n  metaInfo<\/span>:<\/span> { \n     <\/span>\n    title<\/span>:<\/span> '\u6211\u662f index \u9875\u9762\u7684title'<\/span>,<\/span>\n    meta<\/span>:<\/span> [<\/span>\n      { \n     <\/span>\n        name<\/span>:<\/span> 'keywords'<\/span>,<\/span>\n        content<\/span>:<\/span> '\u6211\u662f index \u9875\u9762\u7684keywords'<\/span>\n      }<\/span>,<\/span>\n      { \n     <\/span>\n        name<\/span>:<\/span> 'description'<\/span>,<\/span>\n        content<\/span>:<\/span> '\u6211\u662f index \u9875\u9762\u7684description'<\/span>\n      }<\/span>\n    ]<\/span>\n  }<\/span>,<\/span>\n}<\/span>\n<\/code><\/pre>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"vue\u9879\u76eeSEO\u4e0d\u53cb\u597d\u600e\u4e48\u529e\uff1fSEO\u662f\u7531\u82f1\u6587SearchEngineOptimization\u7f29\u5199\u800c\u6765\uff0c\u4e2d\u6587\u610f\u8bd1\u4e3a\u201c\u641c\u7d22\u5f15\u64ce\u4f18\u5316\u201d","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/7461"}],"collection":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/comments?post=7461"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/7461\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=7461"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=7461"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=7461"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}