How to change og meta tags dynamically on Sapper.js project

1.3k Views Asked by At

I am working on a Sapper.js with Strapi blog. I want to use share social buttons for sharing each blog post. Do you know how can i change the og meta tags dynamically as each blog post would take his photo and title. I tried with svelte:head but it doesn't work. Thanks.

2

There are 2 best solutions below

7
On

<svelte:head> is the way to do this. It should be as simple as setting up the meta tags inside.

Can you see the tags in the source code when you inspect it? Have you checked if the tags are being rendered on the server? Does it work if you hard-code the values?

0
On

<svelte:head>
    <title>{title}</title>
    <!-- open graph (og) SEO  -->
    <meta property="og:title" content={title} />
    <meta property="og:image" content={coverImageUrl} />
</svelte:head>