Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to notify GoogleBot about 404 pages in Angular SPA?

probably duplicate question Best way to set up 404 pages in a angular SPA? but I didn't find a reliable answer for my question .
I'm curious to know if there is a way to tell googlebot about a 404 page ? there is a tag for this purpose called prerender-status-code but I'm didn't find any official article from Google Seo Team to confirm that they respect this meta tag .
is this enough to follow the best practice specify in here ?
or should I do something more ? (perhaps something to do with Google Webmaster tools ?)
I do a research on a few well known SPAs and I noticed SoundCloud add a nofollow tag on their 404 pages , like this :

<meta content="noindex, nofollow" name="robots">

does googlebot respect a meta tag which has been added later by js ?

like image 952
Mahdi Zareie Avatar asked Mar 14 '16 14:03

Mahdi Zareie


1 Answers

You can dynamically add a meta tag in your 404 component:

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

@Component({
  selector: 'app-notfound',
  templateUrl: './notfound.component.html',
  styleUrls: []
})
export class NotFoundComponent {

  constructor(private meta: Meta) {
    meta.addTag({ name: "robots", content: "noindex" });
  }

Google do it themselves on the angular.io site: https://github.com/angular/angular/blob/7b56daffe68c1874ece7ac3b5e252e1edfed980a/aio/src/index.html

like image 118
Richard Avatar answered Oct 01 '22 17:10

Richard