Can i use noindex in a javascript to stop crawling

Maria Jhon

Newbie
Joined
Sep 9, 2019
Messages
1
Reaction score
0
Hello,
I have a question, If I am using a javascript to fill a form on my single webpage. Then can I use noindex to stop crawling to my form?


waiting for a reply. Thanks in advance
 
Noindex tags remove pages from Google's index of searchable pages. Nofollow tags stop Google from crawling links on the page. You can use them together or separately. All you have to do is add the code for one or each of the tags into your page's header HTML.

Within the HTML , that has the javascript embedded, yes you can.
 
You can use JavaScript to add a meta robots tag to a page or change its content. The following example code shows how to change the meta robots tag with JavaScript to prevent indexing of the current page if an API call doesn't return content.
fetch('/api/products/' + productId)
.then(function (response) { return response.json(); })
.then(function (apiResponse) {
if (apiResponse.isError) {
// get the robots meta tag
var metaRobots = document.querySelector('meta[name="robots"]');
// if there was no robots meta tag, add one
if (!metaRobots) {
metaRobots = document.createElement('meta');
metaRobots.setAttribute('name', 'robots');
document.head.appendChild(metaRobots);
}
// tell Googlebot to exclude this page from the index
metaRobots.setAttribute('content', 'noindex');
// display an error message to the user
errorMsg.textContent = 'This product is no longer available';
return;
}
// display product information
// ...
});

Source Link: https://developers.google.com/searc... a meta robots tag,page or change its content.
 
Back
Top