Dynamic Facebook Open Graph tags possible?

前端 未结 3 1107
北恋
北恋 2020-11-30 10:15

I\'m dynamically changing my and tags using jQuer

3条回答
  •  醉酒成梦
    2020-11-30 10:53

    As said previously, Facebook doesn't parse JavaScript at all.

    One way of doing it (the way I do it) is to use a prerendering service like prerender.io to prerender your pages and redirect requests coming from web crawlers to that prerendering server based on the user-agent (you can easily find how to do that with your Nginx/Apache server on google).

    Prerendering services produce an HTML/CSS render of your page, but they wait until the page is fully loaded and the JavaScript is executed before doing so. That way, Facebook gets a render of your website where the JavaScript has been executed and the OpenGraph tags are set correctly!

    Prerender is open-source so you can run your own prerender server for free!

提交回复
热议问题