Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
// update existing robots tag if one is there
const oldRobots = document.querySelector("[name='robots']");
if (oldRobots) {
oldRobots.content = "noindex";
} else {
// add one if none existed
const newRobots = document.createElement('meta'); = "robots";
newRobots.content = "noindex";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment