How to set dynamic Meta Tags and Open Graph tags in polymer?

做~自己de王妃 提交于 2019-11-30 18:49:17
Pensierinmusica

It's definitely an open issue, and it concerns any way to generate meta tags on the client side, whether it's Polymer or any other front-end code.

It can be overcome only if the crawlers execute JS. On May 2014 Google started doing so. On the other hand, as far as I know Facebook has not moved in this direction yet.

You might want to check out these other two answers to get a complete picture:

As of today, the only 100% reliable way is for the server to intercept crawlers and specifically render content for them before sending the response. This is also knwon as isomorphic JavaScript. There already are some useful tools out there to support such tasks, like Prerender.

Hope this helps! Cheers

If you host your Polymer app with Firebase, you can prerender the index.html file with a Firebase http trigger function.

exports.host = functions.https.onRequest((req, res) => {
  // replace og-tags in the index.html file and return it
});

See this post for more info.

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