If you find yourself in a situation where you want Google to index certain pages, but are required to use a template that uses the “nofollow” robots.txt meta tag, is it possible to use JavaScript to remove the tag when the page is fully rendered so that Google will index it?

This was a recently posted question found in the TechSEO subreddit.  John Mueller, Google Senior Webmaster Trends Analyst, responded that Google will use the most restrictive setting you have on the page, no matter how it’s included.

Including the “noindex” tag in your page is basically the most restrictive condition you can apply to it.  In this case you’re telling Google to ignore the page.  If a page that includes a “noindex” in static HTML, and you utilize JavaScript to remove it when the page renders, Google will still see the “noindex” and comply with the request.

“Noindex” overrides other robots.txt meta tags as well. As an example, by including “noindex” + “index”, the “noindex” will override the “index.” Moreover, if a page doesn’t even have any meta tags, and for some reason you use JavaScript to add a “noindex” tag, Google will honor the “noindex” request.

Basically, JavaScript can be quite powerful for workarounds when it comes to limitations or requirements, but in the case of “noindex,” it won’t work when cancelling out the impact of a noindex meta tag embedded in a template.

Source –