[英]Prerendering Angular 6 (for SEO) does not translate routerLink to Href
I am using prerender.io to render angular 6 pages using headless chrome. 我正在使用prerender.io使用无头的chrome渲染角度6页。 The problem is that the renderer does not render the router links and the link information gets lost.
问题是渲染器不渲染路由器链接,并且链接信息丢失。
This is especially problematic, given that the purpose of rendering is SEO. 鉴于渲染的目的是SEO,因此这尤其成问题。
For example, a button with [routerLink]="previewLink", will be rendered to a button with no router link. 例如,带有[routerLink] =“ previewLink”的按钮将呈现为没有路由器链接的按钮。
Here is a live example 这是一个真实的例子
rendered page with no links 没有链接的渲染页面
https://prerender.io/raw-html?url=https%3A%2F%2Fwww.fiveabook.com%2Fbooks&adaptiveType=desktop https://prerender.io/raw-html?url=https%3A%2F%2Fwww.fiveabook.com%2Fbooks&adaptiveType=desktop
No href and no router link in the "Preview" buttons: “预览”按钮中没有href和路由器链接:
<button _ngcontent-c12="" color="accent" mat-button="" tabindex="0" class="mat-button mat-accent ng-star-inserted"><span class="mat-button-wrapper">
angular page with router links 带路由器链接的角度页面
https://www.fiveabook.com/books https://www.fiveabook.com/books
The buttons have dynamically generated router links. 这些按钮具有动态生成的路由器链接。
If I load https://www.fiveabook.com/books directly in my Chrome browser on my Mac and look for that button, I'm not seeing an href there either: 如果我直接在Mac上的Chrome浏览器中加载https://www.fiveabook.com/books并查找该按钮,那么我也看不到href:
So it looks like we are rendering the page exactly as a normal Chrome browser is rendering it. 因此,看起来我们所呈现的页面与普通Chrome浏览器所呈现的完全相同。
Html buttons dont have a href attribute. HTML按钮没有href属性。 Simply use an anchor element if you want to generate a hyperlink button.
如果要生成超链接按钮,只需使用锚元素 。
<a mat-button [routerLink]="...">
Link
</a>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.