Nuxt Content

Integrating Nuxt SEO with Nuxt Content.

Introduction

Most Nuxt SEO modules integrates with Nuxt Content out of the box.

  • Nuxt Robots: robots (docs)
  • Nuxt Sitemap: sitemap (docs)
  • Nuxt OG Image: ogImage (docs)
  • Nuxt Schema.org: schemaOrg (docs)
  • Nuxt Link Checker: Uses content APIs to check links

For Nuxt Content v3 you would need to configure the modules to work with Nuxt Content individually, however, Nuxt SEO provides a way to configure all modules at once.

For Nuxt Content v2, please see the individual module documentation for how to configure them.

Setup Nuxt Content v3

In Nuxt Content v3 we need to use the asSeoCollection() function to augment any collections to be able to use the SEO modules.

content.config.ts
import { defineCollection, defineContentConfig } from '@nuxt/content'
import { asSeoCollection } from '@nuxtjs/seo/content'

export default defineContentConfig({
  collections: {
    content: defineCollection(
      asSeoCollection({
        type: 'page',
        source: '**/*.md',
      }),
    ),
  },
})

To ensure the tags actually gets rendered you need to ensure you're using the SEO composable.

[...slug
<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()
})
if (page.value?.ogImage) {
  defineOgImage(page.value?.ogImage) // <-- Nuxt OG Image
}
// Ensure the schema.org is rendered
useHead(page.value.head || {}) // <-- Nuxt Schema.org
useSeoMeta(page.value.seo || {}) // <-- Nuxt Robots
</script>

Due to current Nuxt Content v3 limitations, you must load the Nuxt SEO module before the content module.

export default defineNuxtConfig({
  modules: [
    '@nuxtjs/seo',
    '@nuxt/content' // <-- Must be after @nuxtjs/seo
  ]
})

Usage

For the full options available for each module, please see the individual module documentation.

---
ogImage:
  component: HelloWorld
  props:
    title: "Hello World"
    description: "This is a description"
    image: "/hello-world.png"
sitemap:
  lastmod: 2025-01-01
robots: index, nofollow
schemaOrg:
  - "@type": "BlogPosting"
    headline: "How to Use Our Product"
    author:
      type: "Person"
      name: "Jane Smith"
    datePublished: "2023-10-01"
---

# Hello World
Did this page help you?