Config Using Route Rules

Learn how to configure robots through route rules.

If you prefer, you can use route rules to configure how your routes are indexed by search engines.

You can provide the following rules:

  • { robots: false } - Will disable the route from being indexed using the robotsDisabledValue config.
  • { robots: <string> } - Will add the provided string as the robots rule

The rules are applied using the following logic:

  • X-Robots-Tag header - SSR only,
  • <meta name="robots"> - When using the defineRobotMeta or RobotMeta composable or component
  • /robots.txt disallow entry - When disallowNonIndexableRoutes is enabled

Inline Route Rules

Requires enabling the experimental inlineRouteRules, see the defineRouteRules documentation to learn more.

<script lang="ts" setup>
  robots: false,

Nuxt Config

export default defineNuxtConfig({
  routeRules: {
    // use the `index` shortcut for simple rules
    '/secret/**': { robots: false },
    // add exceptions for individual routes
    '/secret/visible': { robots: true },
    // use the `robots` rule if you need finer control
    '/custom-robots': { robots: 'index, follow' },