Ahzrael
Ahzrael

Reputation: 189

Angular2 set meta title and description

I created an angular2 website and while i build it i setup the meta title and description along the lines of what this tutorial did http://blog.devcross.net/2016/03/20/angular-2-seo/. This seemed to work and the title in the browser actual updated ok. The problem is that when i do a view source of the site it still only shows me the html source which resides in the main index.html file not the updated values.

When i check the source in the console with firebug lite it shows me updated meta titles and the description.

What am i doing wrong or missing?

Upvotes: 3

Views: 1320

Answers (2)

Günter Zöchbauer
Günter Zöchbauer

Reputation: 657238

Since Angular4-beta.0 there is the Meta service

constructor(private meta:Meta) {
  meta.addTag({ name: 'description', content: 'your description' })
}

For more details see https://github.com/angular/angular/pull/12322/files#diff-7979e98d95c45d21e56cf2602244f220R36

Upvotes: 4

Vinicius Dias
Vinicius Dias

Reputation: 689

When you see the page's source code, no javascript is executed, so you will not be able to see the changes aplied by Angular. This is normal. You aren't doing anything wrong based on that.

Upvotes: 3

Related Questions