Open Graph (OG) tags mainly control how your content appears when shared on social platforms. However, they can also provide better content understanding for web crawlers, similar to Schema.org.
There are 60+ possible OG tags but most have specific use cases.
<meta property="og:title" content="Your title that matters">
<meta property="og:description" content="Short description">
<meta property="og:image" content="https://mysite.com/og.png">
<meta property="og:url" content="https://mysite.com/page">
You should handle your OG tags with useSeoMeta(),
this handles the use property attribute, which can be easy to forget.
useSeoMeta({
ogTitle: 'Hey! Open graph images are important, check them out.',
ogDescription: 'But who reads the description anyway?',
ogImage: 'https://mysite.com/og.png', // must be absolute URL
ogUrl: 'https://mysite.com/products/item' // this is your canonical url
})
See the dedicated og:title and og:description sections for more details on these.
og:imageThe most important tag - invest time here.
Some rules:
twitter:card tag for Xog:image:alt for accessibilityThere are several other properties, including them can be useful to ensure the image is being displayed correctly.
useSeoMeta({
// ✅ use absolute URLs
ogImage: 'https://mysite.com/og-images/product-preview.jpg',
ogImageAlt: '3 boxes on top of each other',
// Optional
ogImageWidth: 1200,
ogImageHeight: 600,
ogImageType: 'image/jpeg',
ogImageUrl: 'https://mysite.com/og-images/product-preview.jpg',
// X specific tags
twitterCard: 'summary_large_image',
twitterImage: 'https://mysite.com/og-images/product-preview.jpg',
twitterImageSrc: 'https://mysite.com/og-images/product-preview.jpg'
})
Create dynamic images using Nuxt OG Image.
og:type{lang="ts}Use this to provide context to crawlers. Common values are website, article, book, profile.
useSeoMeta({
ogType: 'article'
})
og:url{lang="ts}Use this when setting your canonical URL, they should match exactly.
useHead({
link: [
{ rel: 'canonical', href: 'https://mysite.com/products/item' }
]
})
useSeoMeta({
ogUrl: 'https://mysite.com/products/item',
})
Use Vue's reactivity to handle dynamic content.
og data within onMounted as it won't be available to crawlers.<script setup lang="ts">
const { data: product } = await useAsyncData(() => fetchProduct())
useSeoMeta({
// Computed syntax keeps it reactive
ogTitle: () => product.value.name,
ogDescription: () => product.value.shortPitch,
// Generate dynamic OG images - must be absolute
ogImage: () => `https://mysite.com/api/og?title=${product.value.name}`
})
</script>
Always test your OG tags:
useSeoMeta({
ogType: 'article',
author: 'Harlan Wilton',
// open graph
articleAuthor: ['Harlan Wilton'],
articleSection: 'SEO Tutorials for Nuxt',
articleTag: page.value.keywords,
articlePublishedTime,
articleModifiedTime,
// slack unfurling
twitterData1: 'Harlan Wilton',
twitterLabel1: 'Author',
twitterData2: page.value.readTime,
twitterLabel2: 'Read Time',
})
Meta Description
Meta descriptions get rewritten by Google 70% of the time anyway. Here's how to implement them properly in Nuxt using composables and let your content do the heavy lifting.
Schema.org
Schema.org can help search engines understand your content better, but is it worth the effort? Learn when to use it and when to skip it in Nuxt applications.