I want to set dynamic information in meta tag using API call. When I check by inspect, it will show updated data but when I share the link on Facebook it will not reflect updated data.
Index.html
<meta name="description" content="Create and share your biography">
<meta name="og:url" content="window.location.href">
<meta name="og:title" content="TEACHERLIFE -SPANISH LESSONS">
<meta name="og:description" content="So I’m in my classroo...">
In component.ts :
import { Meta, Title } from '@angular/platform-browser';
constructor(private metaService: MetaService,
private meta: Meta,) {}
ngOnInit() {
this.meta.updateTag( {name: 'og:description', content:"testdescription"});
}
3
Answers
Facebook Share doesnot parse the javascript, so it only intercept the static metadata on index.html page.
Please refer to full discussion in github community.
https://github.com/jvandemo/angular-update-meta/issues/13
By default, angular does not use server side rendering. For SEO purpose, you need to add Angular Universal in your project so that server side rendering gets enabled. Then SEO meta tags will work.
https://angular.io/guide/universal
Below is the YouTube tutorial which I came across which explains the concept.
https://www.youtube.com/watch?v=lncsmB5yfzE