DEV Community

Cover image for Updating OG meta tag issue in angular
saajan-pixel
saajan-pixel

Posted on

Updating OG meta tag issue in angular

Updating OG meta tags issue

<!-- Open Graph meta tags for Facebook -->
<meta
property="og:url"
content="https://demo.ndplhrm.com/"

<meta
property="og:type"
content="website"

<meta
property="og:title"
content="Your App Title"

<meta
property="og:description"
content="Description of your app"

<meta
property="og:image"
content="https://images.unsplash.com/photo-1682686581221-c126206d12f0?q=80&w=1770&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDF8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D"

This is OG meta tag declared in index.html file of Angular. In one of component i need to update this meta tags. I have used Meta Service provided by @angular/platform-browser to update meta tags but the tags doesnot get updated.

Note: SSR is not implemented

In the attached image, on clicking facebook icon i have updated the meta tags.

Top comments (2)

Collapse
 
geromegrignon profile image
Gérôme Grignon

The Meta service runs JavaScript to update the meta tags but browser won't executed JavaScript while indexing your page.
That's why you need SSR or SSG to generate the proper meta tags before the browser loads the page.

Collapse
 
saajanpixel profile image
saajan-pixel

Thank you for your response.