Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] How to pass multiple options? #97

Open
kwiat1990 opened this issue Apr 7, 2023 · 5 comments
Open

[Question] How to pass multiple options? #97

kwiat1990 opened this issue Apr 7, 2023 · 5 comments

Comments

@kwiat1990
Copy link

Hey, I have multiple options for different bots, which look like this:

 User-agent: Googlebot
    Disallow: /nogooglebot/

    User-agent: *
    Allow: /

    Sitemap: `${process.env.CMS_URL}/sitemap/index.xml`

I wonder how I could mirror this file with the robots plugin? I have tried using an array for the rules but it returns only the last entry:

// config
robots: {
    rules: [
      {
        UserAgent: "Googlebot",
        Disallow: "/nogooglebot/",
      },
      {
        UserAgent: "*",
        Allow: "/",
      },
      { 
        Sitemap: `${process.env.STRAPI_URL}/sitemap/index.xml`
      },
    ],
  },

// robots.txt page:
User-agent: *
Disallow: 
@abyshake-anand
Copy link

robots: [
    {
        UserAgent: 'Googlebot',
        Disallow: [
            '/nogooglebot/'
        ]
    },
    {
        UserAgent: '*',
        Allow: '/',
    },
]

@kwiat1990
Copy link
Author

@abyshake-anand the output on the robot.txt is the same and contains only the last object:

User-agent: *
Disallow: 

@abyshake-anand
Copy link

Can you share your complete config that relates to robots? This is the output I get when I use the following config.

modules: [
  // ....
  '@nuxtjs/robots',
  // ....
],
robots: [
  {
    UserAgent: 'Googlebot',
    Disallow: ['/user', '/admin'],
  },
  {
    UserAgent: '*',
    Disallow: '/admin',
  },
],

image

@kwiat1990
Copy link
Author

I have tried with the very same config but got the output you can see in my previous message. I’ve also restarted dev server and even change user agent in Chrome to googlebot but it didn’t make any difference at all.

@yauri-io
Copy link

Sorry for messing the PR history.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants