OG Images

Every docs page gets a social sharing image (OG image) generated at build time. This page covers the fields the built-in template reads, generating images for custom pages, replacing the template, and what happens when the feature is off.
View source

How it works

OG images are provided by nuxt-og-image. The feature is on by default and its dependencies ship with the layer, so nothing extra is needed.

  • Docs pages, the home page, the releases page and the showcase page all call the built-in NuxtSeo.takumi template and set og:image and twitter:image;
  • The layer enables ogImage.zeroRuntime: images are rendered to static files by the Takumi renderer during prerendering and never generated on the fly in production, so only prerendered pages have OG images;
  • ogImage.buildCache is enabled, so images are cached on disk and later builds reuse the results for unchanged pages.
OG image generated for a docs page

Template fields

The built-in NuxtSeo.takumi template lives in layer/app/components/OgImage/NuxtSeo.takumi.vue and accepts these props:

PropTypeDefaultDescription
titlestring'title'Main title, up to three lines
descriptionstring-Text below the title
siteNamestring-Site name at the top
colorMode'light' | 'dark''light'Color scheme
isProboolean-Switch to a purple accent
widthnumber1200Image width
heightnumber600Image height

Docs pages fill these fields from the page frontmatter:

FieldValue
titleseo.title, falling back to title
descriptionseo.description, falling back to description
siteNamesite.name from the site config

Set seo.title and seo.description in the frontmatter, and the sharing image and search results use the same title and description.

Custom pages

For custom Vue pages under app/pages/, call defineOgImage inside an import.meta.server branch. Link to the page from a prerendered page so the crawler can discover it, or add its path to nitro.prerender.routes.

app/pages/showcase.vue
<script setup lang="ts">
const title = 'Showcase'
const description = 'Docs sites built with Movk Nuxt Docs'

useSeoMeta({ title, description })

if (import.meta.server) {
  defineOgImage('NuxtSeo.takumi', {
    title,
    description,
    siteName: useSiteConfig().name
  })
}
</script>

Replace the template

The template is a regular component. Create a file with the same name, NuxtSeo.takumi.vue, under app/components/OgImage/ in your project to override the layer's implementation; every page then uses the new template:

app/components/OgImage/NuxtSeo.takumi.vue
<script setup lang="ts">
defineProps<{
  title?: string
  description?: string
  siteName?: string
}>()
</script>

<template>
  <div class="w-full h-full flex flex-col justify-between p-16 bg-[#f6f3ee] text-[#1a1a1a]">
    <span class="text-[28px] tracking-[0.2em] uppercase text-[#c8392f]">{{ siteName }}</span>
    <div class="flex flex-col gap-6">
      <h1 class="text-[72px] font-bold leading-tight m-0">{{ title }}</h1>
      <p v-if="description" class="text-[30px] opacity-70 m-0">{{ description }}</p>
    </div>
  </div>
</template>

The .takumi part of the file name selects the Takumi renderer, so keep that suffix. For the CSS and markup the renderer supports, follow nuxt-og-image and the layer's built-in template.

To give a single custom page a different design, create a component with another name (such as OgImage/Feature.takumi.vue) and call defineOgImage('Feature.takumi', { ... }) on that page. Built-in pages are unaffected.

Turn OG images off

If you do not need sharing images, or want shorter builds, turn the feature off in nuxt.config.ts:

nuxt.config.ts
export default defineNuxtConfig({
  movkNuxtDocs: {
    ogImage: false
  }
})

With it off, nuxt-og-image is not registered and defineOgImage is replaced by a no-op: calls in the layer and in your own pages stay in place and do nothing, so there is no need to remove them or add conditions. See Feature Flags for the other switches.

Copyright © 2024 - 2026