Is it possible to disable Google indexing of some web page if this is placed to head tag

<meta name="googlebot" content="noindex" />

using only JS? Or is it all a hoax and only the finished page is taken into account when indexing?

  • I doubt it. This would assume that Googlebot (a) parses the Javascript as you would like it to and (b) actions it. As, AFAIK this is not standard it would not work. Why not just use robots.txt instead?
    – davidgo
    Jan 29 at 1:10
  • What about Single Page Application ? Google wrote that it already knows how to analyze JS in page. Jan 29 at 8:59

1 Answer 1


Google supports inserting meta tags with JavaScript, including noindex. You can have JavaScript insert <meta name="googlebot" content="noindex" /> into the <head> of the page and Google will stop indexing the page once it renders it.

Google recommends inserting noindex with JavaScript in its documentation: Understand JavaScript SEO Basics | Google Search Central  |  Google Developers

Avoid soft 404 errors in single-page apps

In client-side rendered single-page apps, routing is often implemented as client-side routing. In this case, using meaningful HTTP status codes can be impossible or impractical. To avoid soft 404 errors when using client-side rendering and routing, use one of the following strategies:

  • Use a JavaScript redirect to a URL for which the server responds with a 404 HTTP status code (for example /not-found).
  • Add a <meta name="robots" content="noindex"> to error pages using JavaScript.


Here is sample code for the noindex tag approach:

.then(response => response.json())
.then(product => {
  if(product.exists) {
    showProductDetails(product); // shows the product information on the page
  } else {
    // this product does not exist, so this is an error page.
    // Note: This example assumes there is no other meta robots tag present in the HTML.
    const metaRobots = document.createElement('meta');
    metaRobots.name = 'robots';
    metaRobots.content = 'noindex';

The usual caveats about JavaScript rendering and SEO apply: It often takes Google extra time (weeks or even a couple months) to decide that it needs to render the page, render it, and react to the results. In other words inserting noindex with JavaScript is not likely to be as fast as inserting it into the HTML code on the back end.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.