How to fix “Googlebot Cannot Access Your JavaScript and CSS Files”
If you have recently checked your Google Webmaster tools dashboard to find a message from Google titled “Googlebot Cannot Access Your JavaScript and CSS Files”, don’t be alarmed – Google has sent this message out to hundreds of thousands of webmasters throughout August and they will likely continue to do so for the next couple of months too.
The full message reads:
“Google systems have recently detected an issue with your homepage that affects how well our algorithms render and index your content. Specifically, Googlebot cannot access your JavaScript and/or CSS files because of restrictions in your robots.txt file. These files help Google understand that your website works properly so blocking access to these assets can result in suboptimal rankings.”
Now, this sounds bad on first read (especially the part about suboptimal rankings). And if not actioned, Googlebot’s inability to access your JavaScript/ CSS may indeed count against you. But the good news is that there’s an easy fix for this and it shouldn’t take more than a couple of minutes to complete, so long as you can get access to your robots.txt file.
How to let Googlebot access your JavaScript and CSS files
To fix this issue, you’ll need to edit your robots.txt file. This can be found in the file manager of your web host, or via FTP (if you don’t have an FTP desktop client, FileZilla is an excellent and completely free option. Alternatively, SmartFTP is a good option too).
Once you have opened your robots.txt file, look through it for any of following code:
Disallow: /.js$*
Disallow: /.inc$*
Disallow: /.css$*
Disallow: /.php$*
If you see any of this code, remove it. Simply highlight it and press delete because this is what’s causing Googlebot to not be able to access your JavaScript and CSS files. This should fix the issue. But, you can also go one step further if you like by simply editing the code to:
Allow: /.js$*
Allow: /.inc$*
Allow: /.css$*
Allow: /.php$*
This code basically tells Googlebot that it has permission to access your JavaScript and CSS.
How to check if your changes have worked
Now, you may be wondering how you’ll know whether or not your changes have worked.
Well, the easiest way to do this is to use Google’s free Googlebot Fetch tool otherwise known as the Fetch and Render tool. Log in to Google Webmaster tools and select your property and run the test by clicking ‘FETCH AND RENDER’. It might take a little while to complete, but when it does you’ll be able to click through on the result (which will either say ‘complete’ or ‘partial’) and see what Google sees. At the bottom of this page there may be a list of things that Googlebot can’t access. If JavaScript and CSS is not listed, then the changes that you made to your robots.txt file have worked. If JavaScript and CSS is listed, then Google will let you further test your robots.txt from within the dashboard.