简体   繁体   English

Angular4社交媒体Facebook分享页面,包含详细信息

[英]Angular4 Social Media Facebook share page with details

Where is the catch: 渔获物在哪里:

  1. Nginx as serving Angular 4 app Nginx作为Angular 4应用程序
  2. Angular 4 meta tags only reads from base href on FB request path Angular 4元标记仅从FB请求路径上的基本href读取

Angular path can be (example): https://domain.pa/book/12/Book name 角路径可以是(示例): https : //domain.pa/book/12/书名

Nginx is simple setup: Nginx是简单的设置:

root /home/web/dist;
index index.html index.htm;
location / {
expires -1;
try_files $uri $uri/ /index.html;
autoindex on;
}

In Angular App I have write service that works with: 在Angular App中,我可以使用以下写入服务:

import { Meta } from '@angular/platform-browser';

On every page I update meta-tags for Facebook: 在每个页面上,我都会更新Facebook的元标记:

this.meta.updateTag({ property: 'og:type', content: 'article' });
this.meta.updateTag({ property: 'og:site_name', content: 'AdriaOffer' });
this.meta.updateTag({ property: 'og:title', content: config.title });
this.meta.updateTag({ property: 'og:description', content: config.description });
this.meta.updateTag({ property: 'og:image', content: config.image });
this.meta.updateTag({ property: 'og:url', content: config.slug });

and it works well when I change page meta tags are changed. 当我更改页面元标记时,它也可以很好地工作。 Really don't know where to look at, and how to serve meta-data for Facebook Share plug-in. 真的不知道在哪里看,以及如何为Facebook Share插件提供元数据。 Maybe you had some similar issue for SEO single-page web application. 也许您对SEO单页Web应用程序有类似的问题。

Your project is not detected by the bots because it is PreRender . bot无法检测到您的项目,因为它是PreRender If you want the boots to see your content, you should do a Server Side Rendering (SSR). 如果您希望引导程序看到您的内容,则应该执行服务器端渲染 (SSR)。

You should use Angular Universal or (my recomended) Rendertron . 您应该使用Angular Universal或(我推荐) Rendertron

I have been using a combination of angular + prerender since angular versión 1 and this has been my recommendation until I gave a new chance to angular universal. 自从versión1开始,我一直在使用angular + prerender的组合,这一直是我的建议,直到为我提供了一个新的角度通用的机会。

The first time I tried to setup angular universal the documentation was very confused but Know there is an official documentation 我第一次尝试设置Angle Universal时,文档非常混乱,但是知道有官方文档

https://angular.io/guide/universal https://angular.io/guide/universal

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM