Back to Blog
Getting Started with Nuxt 3 Content Module
Web Development

Getting Started with Nuxt 3 Content Module

Learn how to use the Nuxt 3 Content module to build a dynamic blog. Covers installation, configuration, listing posts with ContentList, and rendering with ContentRenderer.

AK
Aysegul Karadan
5 min read
#nuxt #nuxt-content #vue #tutorial #nuxt3-content-module #how-to-use-nuxt-content #nuxt-content-blog #nuxt-content-setup #dynamic-blog-nuxt

Getting Started with Nuxt 3 Content Module

The Nuxt 3 Content module lets you manage and render static or dynamic content in your Nuxt apps. It's perfect for blogs, documentation sites, portfolios, and product catalogs.

Installation

yarn add --dev @nuxt/content

Configuration

Add to nuxt.config.ts:

export default defineNuxtConfig({
  modules: ['@nuxt/content'],
})

Create Content Files

Create a content/blog/ directory and add Markdown files (e.g., my-first-post.md).

List All Blog Posts (index.vue)

<template>
  <div>
    <ContentList path="/blog" v-slot="{ list }">
      <div v-for="post in list" :key="post._path">
        <p>{{ post.title }}</p>
        <NuxtLink :to="post._path">Read more</NuxtLink>
      </div>
    </ContentList>
  </div>
</template>

Render Individual Posts (...slug.vue)

<template>
  <ContentRenderer v-if="data" :value="data" />
</template>

<script setup>
const { path } = useRoute()
const { data } = await useAsyncData(`content-${path}`, () => {
  return queryContent().where({ _path: path }).findOne()
})
</script>

Use Cases

  1. Blogging platform
  2. Documentation website
  3. E-commerce product catalog
  4. Portfolio or personal website
  5. News or magazine site

By following these steps, you can effectively use the Nuxt 3 Content module to create dynamic, content-driven websites.

AK

Aysegul Karadan

Content Creator at WonderCoder. Passionate about modern web development and sharing knowledge with the community.

Enjoyed this post?

Check out more articles on our blog

View All Posts