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. Removing CSS & JS Files from Index

    Removing CSS & JS Files from Index

    Technical SEO Issues
    8 4 994
    • 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.
    • kirmeliux
      kirmeliux last edited by

      Hi,

      Google has indexed a few .CSS and .JS files that belong to our WordPress plugins and themes. I had them blocked via robots, but realized this doesn't prevent indexation (and can likely hurt us since Google wants to access these files).

      I've since removed the robots instructions, submitted a removal request via Search Console, but want to make sure they don't come back.

      Is there a way to put a noindex tag within .CSS and .JS files? Or should I do something with .htaccess instead?

      1 Reply Last reply Reply Quote 1
      • Mobilio
        Mobilio last edited by

        TL;DR - You're hesitated about problem that doesn't exist.

        Googlebot doesn't index CSS or JS files. They index text files, HTML, PDF, DOC, XLS, etc. But doesn't index style sheets or javascript files.

        All you need in WordPress is to create blank robots.txt file where WP is installed with this content:

        User-agent: *
        Disallow:
        Sitemap: http://site/sitemap-file-name.xml

        And that's all. This is explain many times:

        http://googlewebmastercentral.blogspot.bg/2014/05/understanding-web-pages-better.html
        http://googlewebmastercentral.blogspot.bg/2014/10/updating-our-technical-webmaster.html

        kirmeliux 1 Reply Last reply Reply Quote -1
        • kirmeliux
          kirmeliux @Mobilio last edited by

          Unless I'm severely misreading the links provided, which I've read before, it seems Google is stating that they read, render, and sometimes index .CSS and .JS files. Here's an article written a week after the second article you posted.

          The aforementioned WordPress plugin and theme files hosted on my server are indeed showing up in Google SERPs.

          I do not want to prevent Googlebot from reaching these files as they're needed for optimal site performance, but I do want them to be no-indexed. Thus, I don't want robots.txt to prevent crawling, only indexing.

          Let me know if I'm misunderstanding.

          Niels.V 1 Reply Last reply Reply Quote 0
          • Niels.V
            Niels.V @kirmeliux last edited by

            I haven't encountered undesirable .css or .js indexing myself (yet), but as you surmised, maybe this htaccess directive might be worth trying?

            <filesmatch ".(txt|log|xml|css|js)$"="">Header set X-Robots-Tag "noindex"</filesmatch>

            Google seems to support it

            kirmeliux 1 Reply Last reply Reply Quote 2
            • TimHolmes
              TimHolmes last edited by

              I would seriously think again when it comes to blocking/no-indexing your CSS and JS files - Google has in the past stated that if they cannot fully render your site properly then this could lead to poorer rankings.

              You will also likely get notifications in your Search Console as errors for this too.

              Check out this great article from July this year which goes into more details. 

              Niels.V kirmeliux 2 Replies Last reply Reply Quote 1
              • Niels.V
                Niels.V @TimHolmes last edited by

                There's quite a big difference between crawling directives, which block and indexing directives. This article by (former?) Moz user S_ebastian_ is a good foundation read.

                This article at developers.google.com is a good second read. If I'm understanding it right, Google thinks in terms of crawling directives vs indexing / serving directives.

                My attempt at <tl rl="">:</tl>

                crawling = looking, using in any way :: controlled via robots.txt

                indexing / serving = indexing, archiving, displaying snippets in results, etc :: controlled via html meta tags or web server htaccess (or similar for other web servers).

                I'm not convinced yet, that asking for noindex via htaccess causes the same sort of grief that deny in robots.txt causes.

                1 Reply Last reply Reply Quote 0
                • kirmeliux
                  kirmeliux @TimHolmes last edited by

                  Hi Tim,

                  Assigning a noindex tag to these files will not block them, only prevent them from showing in SERPs. This is the intended goal and the reason I deleted my robots.txt file which prevented crawling.

                  1 Reply Last reply Reply Quote 0
                  • kirmeliux
                    kirmeliux @Niels.V last edited by

                    I figured .htaccess would be the best route. Thank you for researching and confirming. I appreciate it.

                    1 Reply Last reply Reply Quote 0
                    • 1 / 1
                    • First post
                      Last post
                    • Removing a site from Google index with no index met tags
                      effectdigital
                      effectdigital
                      1
                      5
                      58

                    • Bing is removed my indexing
                      wearechorus
                      wearechorus
                      0
                      2
                      47

                    • Removing indexed pages
                      Jettynz
                      Jettynz
                      0
                      5
                      105

                    • Should I remove these pages from the Google index?
                      Robbern
                      Robbern
                      0
                      4
                      212

                    • Remove remove
                      KeriMorgret
                      KeriMorgret
                      0
                      4
                      110

                    • Removing indexed website
                      geekwik
                      geekwik
                      0
                      6
                      128

                    • Pages removed from Google index?
                      TomLondon
                      TomLondon
                      0
                      5
                      73

                    • De-indexing thin content & Panda--any advantage to immediate de-indexing?
                      ShaMenz
                      ShaMenz
                      0
                      4
                      1.0k

                    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