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