5

I want to have a chunk of JS in the middle of my page insert a meta-robots element into the <head> based on some arbitrary condition.

Will Google and other search engines recognize this tag the same way as if I hardcoded the HTML into the <head> section?

1
  • 1
    For most search engines no, but for Google that really should be tested since they now try understand pages by executing JavaScript. There are some methods for doing that discussed in this question on SO.
    – dan
    Feb 27 '15 at 4:34
6

No. Google may sometimes execute Javascript to determine content, but it's a very bad idea to rely on Javascript for your site to be crawled as you want it to be.

3

Per these tests by adding robots meta tag will work: https://searchengineland.com/tested-googlebot-crawls-javascript-heres-learned-220157 (Adam Audette on May 8, 2015 at 12:32 pm).

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.