nuxt-modules / robots

Tame the robots crawling and indexing your Nuxt site.
https://nuxtseo.com/robots
413 stars 30 forks source link

Robots.txt output is not what I write in nuxt.config.js #118

Closed elisabetperez closed 2 months ago

elisabetperez commented 7 months ago

Hello, I'm using @nuxtjs/robots version 3.0.0 and whatever I write inside the options of the module is not being displayed in my robots.txt.

This is my module inside nuxt.config.js:

modules: [
    '@nuxtjs/supabase',
    '@nuxtjs/sanity',
    ['@nuxtjs/robots', {
      UserAgent: '*',
      Disallow: '',
      BlankLine: true ,
      Comment: 'Comment here',
    }]
  ],

and my output is simply:

User-agent: *
Disallow: 

Could you help me find it why? Thanks

kreativwolke commented 7 months ago

Hello :-) Your configuration is not correct.

It should look like this.

modules: [ '@nuxtjs/supabase', '@nuxtjs/sanity', ['@nuxtjs/robots', { rules: [ { UserAgent: '*' }, { Disallow: '' }, { BlankLine: true }, { Comment: 'Comment here' }, ] }] ],

I hope this was helpful.

eric-scott-owens commented 5 months ago

@kreativwolke, it might be worth including your code in the sample on the readme. It's definitely documented. But, I ended up here trying to figure it out as well.

Hoan-Duong commented 4 months ago

same here !

Hoan-Duong commented 4 months ago

Hello :-) Your configuration is not correct.

It should look like this.

modules: [ '@nuxtjs/supabase', '@nuxtjs/sanity', ['@nuxtjs/robots', { rules: [ { UserAgent: '*' }, { Disallow: '' }, { BlankLine: true }, { Comment: 'Comment here' }, ] }] ],

I hope this was helpful.

Thanks, I followed and robots.txt worked!!

bolddkdev commented 3 months ago

Hello Guys,

I'm actually facing the same problem, is it being resolved?

Output: User-agent: * Disallow:

modules: [ "@pinia/nuxt", "@vesp/nuxt-fontawesome", "@ambitiondev/nuxt-cookiebot", "nuxt-swiper", [ "@nuxtjs/robots", { UserAgent: "*", Disallow: "/", }, ], ],

andrzejkupczyk commented 3 months ago

@kreativwolke already provided a solution 🤷🏻 Each rule must be added as a separate array entry (Rule).

There's also an example in the docs https://nuxt.com/modules/robots#robots-config

In your case, @bolddkdev , it should be:

modules: [
    // ...
    ["@nuxtjs/robots", {
        rules: [
            { UserAgent: "*" },
            { Disallow: "/" },
        ],
    }]
],

or

modules: [
    // ...
    "@nuxtjs/robots",
],
robots: {
    rules: [
        { UserAgent: "*" },
        { Disallow: "/" },
    ],
},