Should og:image and og:url put in <meta> or <link>?

后端 未结 2 531
忘了有多久
忘了有多久 2021-01-23 05:31

For og:image and og:url, since they have URL, can I place them in a link tag instead of a meta tag, and is it preferable?

2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-23 05:34

    I don't know about other major consumers of the OGP so this might not be a problem for your case, but if you plan to implement it for Facebook,

    stick to meta tags.

    Doing a quick live test with the open graph debugger and fiddling with the og: tags, it appears that facebook only recognizes them if they are placed in s.

    Try it

    If you create an empty HTML file with a single og:url tag in its section, upload it to any URL and run it through the debugger above, both

    
    

    and

    
    

    edit or, as suggested in the comments

    
    

    will fail to parse and return the original URL, while

     
    

    parses correctly and returns the contents of The Rock on IMDb instead. At the end of the day semantics are nice, but working code is even better.

提交回复
热议问题