The Moz Q&A Forum

    • Forum
    • Questions
    • My Q&A
    • Users
    • Ask the Community

    Welcome to the Q&A Forum

    Browse the forum for helpful insights and fresh discussions about all things SEO.

    1. SEO and Digital Marketing Q&A Forum
    2. Categories
    3. Technical SEO Issues
    4. Dynamically Inserting Noindex With Javascript

    Dynamically Inserting Noindex With Javascript

    Technical SEO Issues
    6 2 599
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as question
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Tom3_15
      Tom3_15 last edited by

      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!

      1 Reply Last reply Reply Quote 0
      • JohnSammon
        JohnSammon last edited by

        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.

        Tom3_15 1 Reply Last reply Reply Quote 1
        • Tom3_15
          Tom3_15 @JohnSammon last edited by

          It looks like it is active. Thanks, John! Can you no-index an entire directory in GSC? I thought it was only per URL.

          1 Reply Last reply Reply Quote 0
          • JohnSammon
            JohnSammon last edited by

            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.
            Tom3_15 1 Reply Last reply Reply Quote 0
            • Tom3_15
              Tom3_15 @JohnSammon last edited by

              It seemed to work. Hopefully the noindex is respected, thank you!

              1 Reply Last reply Reply Quote 0
              • JohnSammon
                JohnSammon last edited by

                Perfect! Happy to help!

                1 Reply Last reply Reply Quote 0
                • 1 / 1
                • First post
                  Last post
                • Brushing up on my SEO skills - how do I check my website to see if Javascript is blocking search engines from crawling the links within a javascript-enabled drop down menu?
                  Martijn_Scheijbeler
                  Martijn_Scheijbeler
                  0
                  3
                  64

                • Noindex Success?
                  GrowthHackingGooglesIndex
                  GrowthHackingGooglesIndex
                  0
                  2
                  71

                • Dynamically changing a title with javascript
                  jfmonfette
                  jfmonfette
                  0
                  5
                  272

                • Dynamic to Static back to Dynamic?
                  komeksimas
                  komeksimas
                  0
                  4
                  357

                • Should I noindex, follow categories?
                  ttb
                  ttb
                  0
                  3
                  877

                • Wordpress noindex
                  JonathanRolande
                  JonathanRolande
                  0
                  15
                  2.6k

                • Javascript usage
                  Naghirniac
                  Naghirniac
                  0
                  6
                  538

                • Javascript data
                  ahming777
                  ahming777
                  0
                  5
                  663

                Get started with Moz Pro!

                Unlock the power of advanced SEO tools and data-driven insights.

                Start my free trial
                Products
                • Moz Pro
                • Moz Local
                • Moz API
                • Moz Data
                • STAT
                • Product Updates
                Moz Solutions
                • SMB Solutions
                • Agency Solutions
                • Enterprise Solutions
                • Digital Marketers
                Free SEO Tools
                • Domain Authority Checker
                • Link Explorer
                • Keyword Explorer
                • Competitive Research
                • Brand Authority Checker
                • Local Citation Checker
                • MozBar Extension
                • MozCast
                Resources
                • Blog
                • SEO Learning Center
                • Help Hub
                • Beginner's Guide to SEO
                • How-to Guides
                • Moz Academy
                • API Docs
                About Moz
                • About
                • Team
                • Careers
                • Contact
                Why Moz
                • Case Studies
                • Testimonials
                Get Involved
                • Become an Affiliate
                • MozCon
                • Webinars
                • Practical Marketer Series
                • MozPod
                Connect with us

                Contact the Help team

                Join our newsletter
                Moz logo
                © 2021 - 2026 SEOMoz, Inc., a Ziff Davis company. All rights reserved. Moz is a registered trademark of SEOMoz, Inc.
                • Accessibility
                • Terms of Use
                • Privacy