Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 2 and SEO meta tags

I have Angular 2 web site and I want to add meta tags (keywords) What is the best?

  • To put all keywords into Index.html page?
  • To put separate tags for each component via .ts code (@angular/platform-browser)?

Are there some difference for the searching machines?

Thank you.

like image 546
CAKA Avatar asked Nov 05 '25 14:11

CAKA


1 Answers

The right solution would be to handle this at the component's level and using services provided by Angular like this:

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

Meta for meta tags like description and keywords and title for the html title

e.g.

constructor(private titleService: Title, private metaService: Meta) {}


this.metaService.addTags([
  { name: 'keywords', content: 'Keyword1, Keyword2' },
  { name: 'description', content: 'Your SEO desc' },
]);


this.titleService('Your seo title');

Putting your meta tags into index.html would mean that you would have the same title, description and keywords for all pages within your app and if it is publicly available website that would be disadvantageous from the SEO point of view.

like image 179
Lukasz Gawrys Avatar answered Nov 07 '25 09:11

Lukasz Gawrys



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!