Facebook Share doesn't pick up title / description meta tags that are changed after page load

喜你入骨 提交于 2019-12-05 19:02:41

This is a quote from Facebook. They scrape the page's meta tags when someone shares that page, and every 24 hours onwards (and not on page-load as you suggested). If you change the meta tags, you need to get FB to "lint" your page again using the URL Linter.

When does Facebook scrape my page?

Facebook needs to scrape your page to know how to display it around the site. Facebook scrapes your page every 24 hours to ensure the properties are up to date. The page is also scraped when an admin for the Open Graph page clicks the Like button and when the URL is entered into the Facebook URL Linter. Facebook observes cache headers on your URLs - it will look at "Expires" and "Cache-Control" in order of preference. However, even if you specify a longer time, Facebook will scrape your page every 24 hours.

Source

Because the facebook server hits the URL you submit and looks for meta tags. It will always default to the original tags.

Its none of Facebook business. They just provide an api for it. And api takes meta tags as parameter. So you set your meta tags to facebook sharing.

I assume that Facebook servers do not execute javascript when they scrape your page.

You could use server-side logic to detect the Facebook user agent and modify the outputted HTML accordingly.

According to the bottom of this page ( http://developers.facebook.com/docs/opengraph/ ), the user agent is currently:

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