Update Facebook Open Graph meta tag through JavaScript

血红的双手。 提交于 2019-11-28 08:59:35
Hans Skov

I'm guessing you figured this out already, but others may have the same problem.

You can't change the Open Graph meta tags with JavaScript after the pageload, as Facebook requests the page from the server again when looking for the meta tags, and so it will not find the updated tags.

Furthermore, I found that Facebook only searches the header for the Open Graph meta tags, so adding them in the body will not work either.

Noah King

Facebook scrapes pages for meta-data only when it is necessary. After you make changes to the metadata, you need to resubmit the object with the 'scrape' parameter set to 'true' in your POST request.

This is outlined in the Open Graph documentation for updating objects.

Anand Agrawal

The meta tags are read by Facebook when shared (liked, etc.), so the JavaScript code might not work. You can test using the online debugger.

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