Error is sometimes a pain that can cost us hundreds of hours. You might have at some point used plugins or has implemented other tricks to improve your WordPress Installation Security. This will in turn lead to “Googlebot cannot access CSS and JS files” Error in WordPress. Now you might have seen tips and tricks to fix it but may have not been too helpful. These warnings seen on Google webmaster tool have instruction to fix it too. But these instruction may not be applicable directly and are not an easy one to follow. I will try to explain in simple words as to what are these errors, their implication and how to remove it.
What are these errors?
These error are thrown if google cannot access these files. Now you may wonder as to why google need these files? Since Google is constantly working on giving their search engine everything to put the best result in front of users. Now they want to test the website in aspects of usability and responsiveness. This is where they require the css and js files.
Normally the wordpress does not block these files but you may have accidentally done it for security. If Google cannot access your site file then it will not be indexed. It will ultimately lead to the degraded SEO performance.
Now lets see how we can see which files are blocked and how to locate them.
How to remove these errors?
Before moving on to solution we need to first clarify the problem and its location. You need to find which of these files are blocked.
Login to your Google webmaster tools and go to Crawl>> Fetch as Google. Click on Fetch and render button. Wait for some time for result to appear.
Once the result is fetched, a row will appear just below it. Click on it and a page will appear. This page will show how the users will see your site and how the googles sees it.
Now you can find which of the files are blocked by looking under the blocked resources. Check out Google Index >> Blocked Resources.
If you open each resources you will be able to find the location of the files. These files should normally be the css files or the js files used by theWordPress plugins or themes.
Now since we have clarified the problem and pointed the resources causing it. Now let’s move on to solution.
Solution to “Googlebot cannot access CSS and JS files” error in in WordPress
Now you will need access to robot.txt file of your site. This is located in the root directory of your site. This is the file which controls what google is allowed to see and and which are not.
You can connect to your site using any FTP Clients like filezilla or anything. You can even login to your cpanel and using the filemanager present there to browse and edit the file.
If by any chance you are using the yoast plugin you can edit the robot.txt file using it too. Just go to the admin area >> SEO >>Tools. You will see the section where the file content for robot.txt is placed.
You can probably see that these directories are not allowed for google to visit.
Now you will need to allow the Google to those directory where your file resides. For examples if your blocked resource is
then you will need to allow the directory /wp-includes/js/ using robot.txt.
To do that it is fairly simple. You will need to add the below lines of codes in the robot.txt file
It will allow every resource residing inside the js folder to be accessed by google bot.
You can add any other folders if there are other resources blocked as shown in the webmaster tool.
Now again Fetch and compare the result from the webmaster tool. Do the same for other resources and you will be good with your site.
Thanks for reading out this article. We hope that you have found it helpful and easy to understand. If you feel anything missing or have any question, do not hesitate to shoot.