1

I have a website hosted in an absurd place. Earlier today, they added this to the "Head" section of my pages.

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

Unfortunately, I cannot change the code directly, but I do have access to Robots.txt (which they also screwed, but I already fixed it), JavaScript and Html. Is there any way I can remove that one tag from my website? I tried this one solution, but it doesn't seem to be working:

document.querySelector('meta[name="robots"]').setAttribute("content", "all");

Any other ways I can do this, besides the obvious "it's about time you move to a different host lol"? Maybe there is, ultimately, something I can add to Robots.txt to override this?

John Conde
  • 217,595
  • 99
  • 455
  • 496
  • If changing hosting provider is so obvious, how come you're still with them? – Laurent S. Aug 15 '20 at 17:27
  • @laurentS. that's a whole different question. For now, I just want to solve this. :P – FlyingDonkey Aug 15 '20 at 17:28
  • Try `document.head.querySelector`, that should work – n9iels Aug 15 '20 at 17:32
  • @n9iels, nope, unfortunately it doesn't work either... – FlyingDonkey Aug 15 '20 at 17:38
  • I am not sure how you're expecting any client-side code to work. AFAIK, bots do not execute client-side code, they just crawl get a static string which is the HTML that your website is serving (i.e., it's like running a `curl` command on your website's address). – Catalyst Aug 15 '20 at 17:50
  • @Catalyst, I'm not sure. As you may understand, I'm not very skilled with this. Does this mean I'm screwed? :/ – FlyingDonkey Aug 15 '20 at 17:52
  • @FlyingDonkey, I am afraid so. :( – Catalyst Aug 15 '20 at 17:54
  • @Catalyst , but... in the past I was able to overlead other things for the bots - yes, these guys screw up THAT often - I just can't seem to find a way to do this one... :( – FlyingDonkey Aug 15 '20 at 17:56
  • You can remove it, but this will probably not solve the Problem you try to fix with this. As Catalyst said, js solutions will have no effect on bots that dont execute js – jjj Aug 15 '20 at 18:09
  • @jjj , I'm sure they use JS, since I've used similar things in the past to settle similar problems, I just can't get this particular one to work... – FlyingDonkey Aug 15 '20 at 18:10
  • [Is it possible to use JavaScript to change the meta-tags of the page?](https://stackoverflow.com/questions/2568760/is-it-possible-to-use-javascript-to-change-the-meta-tags-of-the-page) – kmoser Aug 16 '20 at 02:14

4 Answers4

0

Have you tried removing the meta tag from the dom and adding a new one?

Like this:

document.querySelector("[name='robots']").remove();

let metatag = document.createElement('meta');
metatag.setAttribute('name', 'robots');
metatag.content = 'all';
document.getElementsByTagName('head')[0].appendChild(metatag);
Damian Kociszewski
  • 283
  • 1
  • 5
  • 20
  • For me, simply removing the tag itself would work, but it's not working. Even after I refresh the page and get the new version, Googlebots still tell me the page is Excluded by ‘noindex’ tag... – FlyingDonkey Aug 15 '20 at 17:55
0

You can select the element using this code

document.querySelector("[name='geo.region']")

now once you have access to it, you can override it

Rahul Rana
  • 455
  • 2
  • 7
0

if overriding doesn't work, use a hammer :)

remove the existing meta node

document.querySelector('meta[name="robots"]').remove();

create a new one with desired attribute;

const newMeta = document.createElement("meta");
newMeta.setAttribute("name", "robots");
newMeta.setAttribute("content", "all");
document.head.appendChild(newMeta);
Mechanic
  • 5,015
  • 4
  • 15
  • 38
  • For me, simply removing the tag itself would work, but it's not working, as I said above. Even after I refresh the page and get the new version, Googlebots still tell me the page is Excluded by ‘noindex’ tag... – FlyingDonkey Aug 15 '20 at 17:55
0

After a few hours of considering all kinds of possible solutions, I eventually noticed that a much simpler piece of code could work. Instead of all this, and since I could not remove code but could add to it, I simply added this:

<meta name="robots" content="all" />
<meta name="googlebot" content="all" />

This made it worked... the bots may be feeling confused, "hey, should I index it or not, afterall?!", but it works, and that's what matters to me.

Thank you very much for your help, everyone!