skip to Main Content

I’m trying to populate page title and meta tags with dynamic data coming from api for seo purpose. but unable to get it in view-page-source

I’ve tried useHead, useSeoMeta and useServerSeoMeta with reactive properties. but all these functions called before getting api response. is there any way to get dynamic meta data in view-source-page?

2

Answers


  1. useSeoMeta works for me. Note that values must be functions.

    <script setup>
    
    const id = route.params.id;
    const { data: product } = await useAsyncData(id, () => 
      apiStore.GET_PRODUCT(id),
    );
    
    ...
    
    useSeoMeta({
      title: () => product.value?.name,
      description: () => product.value?.short_description,
      ogTitle: () => product.value?.name,
      ogDescription: () => product.value?.short_description,
      // and other stuff
    });
    
    <script>
    
    Login or Signup to reply.
  2. How can I make my values into a functions for my useSeoMeta guys? I really need ur help guys! :((((((

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search