Nuxt Content
Nuxt Robots comes with an integration for Nuxt Content that allows you to configure robots straight from your markdown directly.
The integration needs Nuxt Content v3. Nuxt Robots v7 does not support Nuxt Content v2.
Setup Nuxt Content v3
Add defineRobotsSchema() to your collection's schema to enable the robots frontmatter key.
import { defineCollection, defineContentConfig } from '@nuxt/content'
import { defineRobotsSchema } from '@nuxtjs/robots/content'
import { z } from 'zod'
export default defineContentConfig({
collections: {
content: defineCollection({
type: 'page',
source: '**/*.md',
schema: z.object({
robots: defineRobotsSchema(),
}),
}),
},
})Use useSeoMeta() to render the meta tag.
Call useRobotsRule() to send the same rule in the X-Robots-Tag header.
Install Zod 4 to use defineRobotsSchema().
<script setup lang="ts">
import { queryCollection, useRoute } from '#imports'
const route = useRoute()
const { data: page } = await useAsyncData(`page-${route.path}`, () => {
return queryCollection('content').path(route.path).first()
})
// Ensure the SEO meta tags are rendered
useSeoMeta(page.value?.seo || {})
// Keep the HTTP header consistent with the frontmatter rule.
useRobotsRule(page.value?.robots ?? undefined)
</script>Nuxt Content v3 works with either module order.
export default defineNuxtConfig({
modules: [
'@nuxtjs/robots',
'@nuxt/content'
]
})Setup comark-content
comark-content is a Markdown-only content module. Nuxt Robots supports it first-party.
No schema opt in is needed. Write the robots key in frontmatter and the module maps it onto the page's seo.robots.
---
robots: false
---
# FooRender it with useSeoMeta() in your catch-all page, the same as with Nuxt Content v3.
<script setup lang="ts">
const route = useRoute()
const { data: page } = await useAsyncData(`page-${route.path}`, () => {
return queryCollection('content').path(route.path).first()
})
useSeoMeta(page.value?.seo || {})
useRobotsRule(page.value?.robots ?? undefined)
</script>See Usage for the values the robots key accepts.
Usage
You can use any boolean or string value as robots that will be forwarded as a
Meta Robots Tag.
robots: false<meta name="robots" content="noindex, nofollow">Disabling the Nuxt Content integration. If you need to disable it, you can do so by setting the disableNuxtContentIntegration option in the module configuration.
export default defineNuxtConfig({
robots: {
disableNuxtContentIntegration: true,
}
})