问题
My website hosted on http://abc.xyz.com OG meta tag works for the main page. If I am adding it to the child routes it doesn't work. for example - http://abc.xyz.com/pqr/slug-url.
index.html
<meta property="og:type" content="article">
<meta property="og:site_name" content="XYZ" >
<meta property="og:title" content="XYZ" >
<meta property="og:description" content="XYZ" >
<meta property="og:image" content="xyz imagepath" >
<meta property="og:url" content="xyz url" >
component.ts
this.meta.updateTag({ property: 'og:type', content: 'article' });
this.meta.updateTag({ property: 'og:site_name', content: 'XYZ' });
this.meta.updateTag({ property: 'og:title', content: config.title });
this.meta.updateTag({ property: 'og:description', content: config.description });
this.meta.updateTag({ property: 'og:image', content: config.image });
this.meta.updateTag({ property: 'og:url', content: config.url });
server.js
app.engine('html', ngExpressEngine({
bootstrap: AppServerModuleNgFactory
}));
app.set('view engine', 'html');
app.set('views', './');
app.use('/', express.static('./', {index: false}));
app.get('*', (req, res) => {
res.render('index', {
req
});
});
If I am checking on developer tool, it shows added meta tags but doesn't reflect on Facebook while posting page.
Thanks.
来源:https://stackoverflow.com/questions/48704717/angular-universal-og-meta-tags-not-working-with-child-routes