Canonical url being linked on Facebook rather than real URL. Dynamic OpenGraph tags coming up empty

蓝咒 提交于 2019-12-12 08:54:26

问题


My website is a jobs website If I share a job at the moment the url could be for example

http://jobs.com/jobs/show-job/143/Jobit-flyers-put-up/Other/

But facebook with try to scrape http://jobs.com/jobs/show-job/ because that is the canonical url.

This really sucks when someone posts it on facebook because all the OpenGraph tags are empty so the link gets the wrong thumbnail and blank information. Who knows how to fix this?


回答1:


Fixed!

Inside the header of the dynamic page you are creating simply user the meta og tag

 <meta property="og:url" content="<?php get_current_url(); ?>" >



回答2:


Canonical URL is the URL that represent your OpenGraph object and this is intended to work that way!

You can see the answer I gave to similar question for more details.




回答3:


Do NOT use the og:type of "website" if you are publishing an "article".

For example:

  • If you said THIS http://jobs.com/show-job/
  • is og:type = website

Then you have told facebook that this:

  • http://jobs.com/jobs/show-job/143/Jobit-flyers-put-up/Other/
  • is canonical for show-job/

Simply put: use the following:

  • og:type = website => http://jobs.com/
  • og:type = article => http://jobs.com/show-job/
  • og:type = article => http://jobs.com/jobs/show-job/143/Jobit-flyers-put-up/Other/

More information here: https://ogp.me/#type_article



来源:https://stackoverflow.com/questions/10266604/canonical-url-being-linked-on-facebook-rather-than-real-url-dynamic-opengraph-t

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