Angular Universal - OG meta tags not working with child routes

ε祈祈猫儿з 提交于 2019-12-11 07:35:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!