Open graph can resolve relative url?

后端 未结 3 875
星月不相逢
星月不相逢 2021-02-06 19:57

I\'m adding Facebook Open Graph meta tag to my site. For example:


Does Open Gr

相关标签:
3条回答
  • 2021-02-06 20:36

    I set up an og:image tag on my website with a relative url, and even though facebook reports an error like this :

    Object at URL 'http://***/' of type 'website' is invalid because the given value 'preview.png' for property 'og:image:url' could not be parsed as type 'url'.

    on https://developers.facebook.com/tools/debug/og/object/, the image shows up in the preview.

    So I guess this is kind of supported, at least on facebook.

    0 讨论(0)
  • 2021-02-06 20:38

    If you are setting the value of the og:url meta node from within a Controller Action you can use:

    Request.Url.AbsoluteUri()

    0 讨论(0)
  • 2021-02-06 20:44

    Documentation have nothing about it, but relative URLs will not work, only full URL including scheme works.

    As long as only full URLs supported you may convert relative to absolute url using URL.Content method (as suggested in What is the equivalent to Page.ResolveUrl in ASP.NET MVC?)

    NOTES:

    • In 2012 in old Facebook bug tracker this bug was closed stating this is "by design" http://developers.facebook.com/bugs/192471680829756
    • If you look into http://ogp.me/ns RDF schema (in Turtle) og:image specified as ogc:url which have next description:

    A string of Unicode characters forming a valid URL having the http or https scheme.

    0 讨论(0)
提交回复
热议问题