nuxt-modules / robots

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

Is domain specific config available? #111

Closed criation closed 2 months ago

criation commented 10 months ago

I do have two domains, lets say

staging.example.com exmaple.com

now i want to have specific robots setting for each domain. It'd be nice to realize this by config like this:

modules: [
    [...],
    ['@nuxtjs/robots', {
      UserAgent: '*',
      Disallow: '/admin',
      domains: {
        'exmaple.com': [
          { UserAgent: '*' },
          { Disallow: '/dashboard/' },
        ],
        'staging.example.com': [
          { UserAgent: '*' },
          { Disallow: '/' }, 
        ]
      }
    }],
  ],

is something like this already available?

kenechukwuJosiah commented 10 months ago

Currently, this module does not support configuration per domain, but you can dynamically generate your robot.txt based on the domain.

quroom commented 5 months ago

@criation Did you solve your problem? Maybe you can acheive what you want with env.


  robots:
    process.env.STAGE === "production"
      ? {
          rules: [
            {
              UserAgent: "*",
              Allow: "/",
              Disallow: "/admin",
            },
          ],
        }
      : {
          rules: {
            UserAgent: "*",
            Disallow: "/",
          },
        },

I just set STAGE but you can set whatever you want as variable in env file. And make your code works conditionally based on domians. I am sure you can acheive what you want in this way.