October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

How to Add Open Graph Tags to a Nuxt 4 Website

Use Nuxt 4's useSeoMeta for shared Open Graph defaults and page-specific titles, images, descriptions, and canonical URLs.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

In Nuxt 4, add Open Graph metadata with useSeoMeta(): put site-wide defaults in app/app.vue and set route-specific values in the relevant page component. At minimum, provide og:title, og:type, og:image, and og:url; a concise description and image alt text make the preview more informative.

Use useSeoMeta for Open Graph metadata

Nuxt recommends useSeoMeta() for metadata: its semantic, typed fields help prevent mistakes such as using name where a tag requires property, and it supports reactive values. The Open Graph property names become camel-cased options: og:title is ogTitle, for example.

As an Amazon Associate I earn from qualifying purchases.

The examples below target Nuxt 4. Nuxt 3 reached end of life on 31 July 2026, so use the Nuxt 4 documentation for current setup guidance.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Add shared defaults

Put defaults in the root application component, app/app.vue. Page components can supply more specific values for their routes.

<!-- app/app.vue -->
<script setup lang="ts">
useSeoMeta({
  ogSiteName: 'Example Site',
  ogType: 'website',
  ogTitle: 'Example Site',
  ogDescription: 'A short description of this website.',
  ogUrl: 'https://example.com/',
  ogImage: 'https://example.com/social-card.jpg',
  ogImageAlt: 'Example Site homepage preview',
})
</script>

Replace the example domain and copy with your own. Treat these as fallbacks: a page with its own metadata should provide values that describe that page.

Set metadata for each page

For a page whose content comes from a route-specific data source, derive the tags from the loaded content. This illustrative example assumes loadArticleForCurrentRoute() and the resulting article object are provided by your application; that function is not a Nuxt API.

<!-- app/pages/articles/[slug].vue -->
<script setup lang="ts">
const article = await loadArticleForCurrentRoute()

useSeoMeta({
  ogType: 'article',
  ogTitle: () => article.value.title,
  ogDescription: () => article.value.summary,
  ogUrl: () => `https://example.com/articles/${article.value.slug}`,
  ogImage: () => article.value.socialImage,
  ogImageAlt: () => article.value.socialImageAlt,
})
</script>

Use the page’s actual canonical URL and an absolute, publicly reachable image URL. Getter functions keep metadata connected to values that may change reactively.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Which Open Graph properties should you set?

The Open Graph Protocol specifies four required properties for every page. Nuxt’s useSeoMeta() uses the corresponding camel-cased keys:

Open Graph property Nuxt key What to provide
og:title ogTitle A clear title for the page’s preview.
og:type ogType The type of object represented, such as website or article.
og:image ogImage An absolute URL to the page’s preview image.
og:url ogUrl The page’s canonical URL and permanent graph identifier.

og:description is optional in the protocol but generally recommended. When you specify an image, also provide og:image:alt (Nuxt key: ogImageAlt) with a description of what the image shows, not a caption. The protocol also defines image MIME type, pixel width, and pixel height subproperties; use them if your implementation needs that extra image metadata.

There is no single image-size rule established here for every social platform. Choose an image appropriate to your intended use and check the requirements of the service where you expect it to appear.

Choose between useSeoMeta, useHead, and app.head

  • useSeoMeta(): The recommended choice for common SEO and social metadata. Its typed semantic fields make Open Graph properties concise, and values can be reactive.
  • useHead(): Use this when you need lower-level control of the document head or want to describe metadata as head objects. Nuxt supports reactive values with this composable.
  • app.head in nuxt.config.ts: Suitable for static defaults. It cannot hold reactive data, so use a composable in app/app.vue or a page component when values depend on route or content.

For example, the lower-level useHead() form expresses Open Graph tags through the meta array and each tag’s property:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
useHead({
  meta: [
    { property: 'og:title', content: 'Example Site' },
    { property: 'og:description', content: 'A short description.' },
  ],
})
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Check the rendered page and troubleshoot previews

If a preview is missing, incorrect, or stale, inspect the rendered HTML document’s <head>, not just the source component. Confirm that the final page contains the intended tags and values.

  • A required tag is absent: Check that the composable runs in the intended app or page component and that the page is actually rendered with the expected data.
  • A global value appears on every route: Add route-specific values in the relevant page component and verify that they override the defaults in the rendered head.
  • The image does not appear: Check that og:image contains an absolute, publicly reachable URL and that the URL identifies the intended image.
  • The URL identifies the wrong page: Set og:url to that page’s canonical URL rather than a shared site URL or a relative path.
  • The title or description is wrong: Inspect the final rendered values and confirm that the data source has loaded the expected route content before those values are used.

These checks verify your Nuxt output and protocol properties; they do not guarantee how a particular social platform will fetch, cache, or display a preview. Crawler-specific cache, authentication, rendering, and image-size behavior varies and is not established here.

Or skip the browser setup

If you need screenshots of pages to review how they look, ScreenshotNeo can return an image or PDF with one GET request. That is separate from setting Open Graph metadata; it does not replace the tags above.

For example, request a screenshot of a public page and save the response as WebP:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp

See the ScreenshotNeo API documentation for request options. ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are never billed. Its MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots a month with no card, and paid plans start at $5 for 3,000. Sign up for free.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.