Dynamically Inserting Noindex With Javascript
-
Hello,
I have a broken plugin creating hundreds of WP-Content directory pages being indexed by Google. I can not access the source code of these pages to add a noindex to them. The page URL's all have the plugin name within them. In order to resolve the issue, I wrote a solution with javascript to dynamically add in a noindex tag to any URL containing the plugin name. Would this noindex be respected by Google and is there a way to immediately check that it is respected?
Currently, I can not delete the plugin due to issues with it's php.
If you would like to view the code: https://codepen.io/trodrick/pen/Gwwaej?editors=0010
Thanks!
-
Perfect! Happy to help!
-
It seemed to work. Hopefully the noindex is respected, thank you!
-
You can! Via https://support.google.com/webmasters/answer/1663419?hl=en
- If you choose to hide a directory, then any file or directory starting with the prefix you supply will be blocked. So if you enter /folder, then /folder/somefile, foldername/somefile, and /folder.html will all be blocked.
- To hide an entire site, leave the path empty.
-
It looks like it is active. Thanks, John! Can you no-index an entire directory in GSC? I thought it was only per URL.
-
Hey there! Do you have a link to a page where it's implemented live? As long as you have the no-index, no follow in there, you should be okay. Other things you can do:
1. Use robots.txt to hide the directory of pages that the plugin is outputting
2. Sign into the Google Search Console and no-index the same directory
I would do 1 and 2 to help speed up things once the no-index, no-follow tag is in place.
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
Good to use disallow or noindex for these?
Hello everyone, I am reaching out to seek your expert advice on a few technical SEO aspects related to my website. I highly value your expertise in this field and would greatly appreciate your insights.
Technical SEO | | williamhuynh
Below are the specific areas I would like to discuss: a. Double and Triple filter pages: I have identified certain URLs on my website that have a canonical tag pointing to the main /quick-ship page. These URLs are as follows: https://www.interiorsecrets.com.au/collections/lounge-chairs/quick-ship+black
https://www.interiorsecrets.com.au/collections/lounge-chairs/quick-ship+black+fabric Considering the need to optimize my crawl budget, I would like to seek your advice on whether it would be advisable to disallow or noindex these pages. My understanding is that by disallowing or noindexing these URLs, search engines can avoid wasting resources on crawling and indexing duplicate or filtered content. I would greatly appreciate your guidance on this matter. b. Page URLs with parameters: I have noticed that some of my page URLs include parameters such as ?variant and ?limit. Although these URLs already have canonical tags in place, I would like to understand whether it is still recommended to disallow or noindex them to further conserve crawl budget. My understanding is that by doing so, search engines can prevent the unnecessary expenditure of resources on indexing redundant variations of the same content. I would be grateful for your expert opinion on this matter. Additionally, I would be delighted if you could provide any suggestions regarding internal linking strategies tailored to my website's structure and content. Any insights or recommendations you can offer would be highly valuable to me. Thank you in advance for your time and expertise in addressing these concerns. I genuinely appreciate your assistance. If you require any further information or clarification, please let me know. I look forward to hearing from you. Cheers!0 -
Javascript redirects harmful for SEO?
Hi Mozzers, A website deals with some javascript redirects. After some research, It came clear a normal 301 is the best option, but javascript redirects can be useful if you don't have access to a website' server. Does anyone have experience with javascript redirects? Can they be harmful in any point of SEO? I would love to hear your thoughts!
Technical SEO | | WeAreDigital_BE0 -
Does Google read dynamic canonical tags?
Does Google recognize rel=canonical tag if loaded dynamically via javascript? Here's what we're using to load: <script> //Inject canonical link into page head if (window.location.href.indexOf("/subdirname1") != -1) { canonicalLink = window.location.href.replace("/kapiolani", ""); } if (window.location.href.indexOf("/subdirname2") != -1) { canonicalLink = window.location.href.replace("/straub", ""); } if (window.location.href.indexOf("/subdirname3") != -1) { canonicalLink = window.location.href.replace("/pali-momi", ""); } if (window.location.href.indexOf("/subdirname4") != -1) { canonicalLink = window.location.href.replace("/wilcox", ""); } if (canonicalLink != window.location.href) { var link = document.createElement('link'); link.rel = 'canonical'; link.href = canonicalLink; document.head.appendChild(link); } script>
Technical SEO | | SoulSurfer80 -
Having javascript in the top of the source code
Dear Moz-community, In our company, we are torn about the influence of having a ton of javascript on the top of our source code - while our Tech guys are downplaying it's influence, us marketeers aren't quite sure. The link is here: view-source:http://www.bettingexpert.com/tips/football/italy/serie-a It is the javascript that is loaded right after the Would this be a problem with Google? Thank you very much,
Technical SEO | | BetterCollective
William0 -
The difference between an noindex and nofollow?
What is really the difference between an noindex and nofollow and why/when do you want to use them? Built my first wordpress site and the blog "posts" that make up my home page confuse me....as far as passing link juice to my home url...not sure what I am asking here! How do I use nofollow/noindex or is the issue I should be looking at is 301/canonical. Or neither?
Technical SEO | | cschwartzel0 -
How to change noindex to index?
Hey, I've recently upgraded to a pro SEOmoz account and have realised i have 14574 issues to do with 'blocked by meta-robot' and that 'This page is being kept out of the search engine indexes by the meta tag , which may have a value of "noindex", keeping this page out of the index.' How can i change this so my pages get indexed? I read somewhere that i need to change my privacy settings but that thread was 3 years old and now the WP Dashboard has updated.. Please let me know Many thanks, Jamie P.s Im using WordPress 3.5 And i have the XML sitemap plugin And i have no idea where to look for this robots.txt file..
Technical SEO | | markgreggs0 -
Search result pages - noindex but auto follow?
Hi guys, I don't index my search pages, and currently my pages are tagged name="robots" content="noindex"> Do I need to specify follow or will it automatically be done? Thanks Cyto
Technical SEO | | Bio-RadAbs0 -
What to do with content that performs well in SERPs, but is dynamically generated?
A new client developed an application that generates dynamic content. They were hit hard from Panda, and I believe it is in part due to this application. About 500 of the urls from this application perform well in SERPs (rank well, drive traffic to the site, low bounce rate, high page views per visit, etc). And there are an additional 9,000 urls (and growing) in the index that don't drive any organic traffic. We are thinking of making the 500 url that perform well into static pages and de-indexing the rest. What are your thoughts on this?
Technical SEO | | nicole.healthline0