Angular2-SEO-如何操作元描述 [英] Angular2 - SEO - how to manipulate the meta description
本文介绍了Angular2-SEO-如何操作元描述的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
搜索结果通过TitleTag和<meta name="description"..."/>
标签显示.
<title>
-Tag可通过Angular2 如何在angular2路由器
Search Results in google are displayed via TitleTag and the <meta name="description"..."/>
Tag.
The <title>
-Tag is editiable via Angular2 how to change page title in angular2 router
剩下的就是说明.
是否可以在angular2中编写指令,以操纵页面<head>
部分中的元标记.
因此,根据所选路线的不同,元描述也会发生如下变化:
Is it possibile to write a directive in angular2, that manipulates the meta-tags in the <head>
part of my page.
So depending on the selected route, the meta description changes like:
<meta name="description" content="**my description for this route**"/>
推荐答案
Since Angular4, you can use Angular Meta service.
import { Meta } from '@angular/platform-browser';
// [...]
constructor(private meta: Meta) {}
// [...]
this.meta.addTag({ name: 'robots', content: 'noindex' });
这篇关于Angular2-SEO-如何操作元描述的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文