首页 > 解决方案 > 禁止使用 @nuxtjs/robots 模块的动态 URL

问题描述

我有以下文件夹结构:

/pages/user/_user

而我当前在 nuxt.config 中的机器人对象

robots: {
 UserAgent: '*',
 Disallow: '/user',
 Sitemap: 
 'https://www.misite.com/sitemap.xml'
},

我没有在模块的文档中找到任何相关内容,所以我想知道如何禁止/_user URL?

标签: nuxt.js

解决方案


不确定是否可以使用 robots 模块,但不要忘记您可以将 noindex 标签添加到用户页面。

<script>
export default {
  head () {
    return {
      meta: [
        { hid: 'robots', name: 'robots', content: 'noindex' }
      ]
    }
  }
}
</script>

推荐阅读