脸书的元数据图像



如果我在这里找到我网站的一些链接,我想使用图像。好吧,我正在使用以下内容:

        import { Meta, Title } from "@angular/platform-browser";
        this.title.setTitle(this.data[0].title + ' - ' + this.data[0].city 
        );
        this.meta.addTags([
          { name: 'keywords', content: 'Globetrotter, Backpacking, Hiking, Travel' + this.data[0].city + ',' + this.data[0].country},
          { name: 'description', content: this.data[0].description},
          { name: 'og:image', content: this.data[0].images[0]}
        ]);
一切正常,

但图像不正常,我不确定是否正确。在我的索引.html文件中,我有另一个图像,并且正在发生这种情况。我应该删除它吗?如何设置自动显示整个站点的 url?

索引.html即使我输入不同的网址路径,Facebook也总是显示此图像。

<meta property="og:image"     content="https://cdn.pixabay.com/photo/2017/09/01/21/53/blue-2705642_960_720.jpg"
 />

我希望Facebook或其他网站从这里识别出图像:

 { name: 'og:image', content: this.data[0].images[0]}

问题可能在于,facebook的爬虫/机器人不执行JavaScript,因此只会看到您在index.html中静态提供的<meta>标签。

您必须使用预呈现服务(如 prerender.io)或在服务器端编写正确的元标记。

最新更新