Robots
Integrations

Nuxt I18n

How to use the Nuxt Simple Robots module with Nuxt I18n.

Out of the box, the robots module will integrate directly with @nuxtjs/i18n. You will need to use v8+ of the i18n module.

Auto-localised Allow / Disallow

The module will automatically localise the allow and disallow paths based on your i18n configuration.

If you provide a allow or disallow path that is not localised, it will be localised for you, if your i18n configuration allows it.

nuxt.config.ts
export default defineNuxtConfig({
  robots: {
    disallow: ['/secret', '/admin'],
  },
  i18n: {
    locales: ['en', 'fr'],
    defaultLocale: 'en',
    strategy: 'prefix',
  }
})

This will generate the following output:

User-agent: *
Disallow: /en/secret
Disallow: /en/admin
Disallow: /fr/secret
Disallow: /fr/admin

Opting-out of localisation

If you want to opt-out of localisation, there are two options:

Opt-out for a group

You can provide the _skipI18n option to a group to disable localisation just for that group.

export default defineNuxtConfig({
  robots: {
    groups: [
      {
        disallow: [
          '/docs/en/v*',
          '/docs/zh/v*',
          '/forum/admin/',
          '/forum/auth/',
        ],
        _skipI18n: true,
      },
    ],
  },
})

Opt-out i18n globally

By providing the autoI18n: false option you will disable all i18n localisation splitting.

export default defineNuxtConfig({
  robots: {
    autoI18n: false,
  }
})