Seo Nuxt站点未被爬网
我已经做了一个网站使用NUXT,需要搜索引擎优化 当我使用该网站查看是否可以找到我的所有页面时,它只找到主页,而没有找到其他路径。当我尝试其他NUXT演示网站时,它会找到所有这些网站 我的Seo Nuxt站点未被爬网,seo,nuxt.js,Seo,Nuxt.js,我已经做了一个网站使用NUXT,需要搜索引擎优化 当我使用该网站查看是否可以找到我的所有页面时,它只找到主页,而没有找到其他路径。当我尝试其他NUXT演示网站时,它会找到所有这些网站 我的robots.txt文件如下所示: User-agent: * Disallow: /profile/ Sitemap: https://www.example.com/sitemap.xml module.exports = { /* ** Headers of the page */ he
robots.txt
文件如下所示:
User-agent: *
Disallow: /profile/
Sitemap: https://www.example.com/sitemap.xml
module.exports = {
/*
** Headers of the page
*/
head: {
title: 'Title',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: 'Title' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
]
},
mode: 'spa',
loading: { color: '#3B8070' },
build: {
/*
** Run ESLint on save
*/
extend (config, { isDev, isClient }) {
if (isDev && isClient) {
config.module.rules.push({
enforce: 'pre',
test: /\.(js|vue)$/,
loader: 'eslint-loader',
exclude: /(node_modules)/
})
}
}
},
css: [
'~/assets/main.css'
],
modules: [
'@nuxtjs/pwa',
[
'@nuxtjs/sitemap', {
generate: true,
hostname: 'https://www.example.com',
exclude: [
'/profile'
]
}
]
],
plugins: [
'~/plugins/uikit.js',
'~/plugins/fireauth.js'
],
manifest: {
name: 'Title',
lang: 'en'
},
router: {
middleware: 'router-auth'
},
vendor: [
'firebase',
'uikit'
]
}
我正在使用@nuxtjs/sitemap
生成sitemap.xml
,结果如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
<url> <loc>https://www.example.com/about</loc> </url>
<url> <loc>https://www.example.com/</loc> </url>
</urlset>
我是nuxt站点地图模块的创建者 您的站点地图模块配置设置在错误的部分 请更新您的
numxt.config.js
:
modules: ['@nuxtjs/pwa', '@nuxtjs/sitemap'],
sitemap: {
generate: true,
hostname: 'https://www.example.com',
exclude: [
'/profile'
]
},
plugins: [
然后运行npm运行generate
最后,在\dist\
文件夹中检查生成的sitemap.xml
(如果您有其他问题,您可以在github项目上打开一个问题:)由于您处于SPA模式,SEO不会取得太大成功,如果您可以在
通用模式下运行,那么您将看到nuxt/vue的全部好处
查看我在通用模式下使用Nuxt的网站。了解不同Nuxt.js模式下的情况非常重要。阅读Nuxt.js指南中的,其中解释了框架可以配置为在三种模式下工作的区别:
- 通用(具有服务器端呈现,因此当呈现任何页面时,该页面将与所有呈现的HTML一起提供(SEO和爬虫友好模式)
- SPA(单页应用程序),它将与css和javascript捆绑包一起提供HTML框架,这些捆绑包只能在浏览器中进行拆分以创建初始DOM。对于intranet应用程序很酷,对于SEO不好。
- 静态生成所有页面(预呈现),以便站点可以在任何共享主机中作为简单HTML提供服务
概念明确后,您可以尝试将Nuxt.js配置文件中的“mode”属性从“SPA”更改为“Universal”,并在同一Nuxt.config.js文件中提供有关xml站点地图配置的其他建议
此外,您还可以通过以下方式尝试和了解不同的配置:
- 安装指南中讨论了这些问题
- 类似的,一旦通过
npm安装-g create nuxt app安装,您就可以查看自动为您设置了多少种不同的配置