Troubleshooting Googlebot Cannot Access WordPress CSS and JS files – Do you see Googlebot can’t access CSS and JS files and there is a warning “Googlebot Cannot Access CSS and JS filesIn your webmaster tools on your WordPress site? The message also contains an instructional link on how to fix this problem, but the instructions are still very confusing to solve the problem. In this article, I will show you how to fix an issue about Googlebot unable to access CSS and JS files on a WordPress site.
Why does Google need access to CSS and JS files?
By default WordPress does not block search bots from accessing any CSS or JS files. However some site owners may accidentally block these files when trying to add additional security measures or by using a security plugin to strengthen a WordPress site. This of course restricts Googlebot from indexing CSS and JS files which can affect performance WordPress SEO.
Now that we know the fact that it will be very important for us to open these files for googlebot to access, now let’s see how you can find these files and unblock them.
How does Google get access to the CSS and JS files?
First you need to do is to find out which files Google cannot access on your website.
You can see how Googlebot views your site by clicking Crawl »Fetch As Google in Google Search Console (formerly Webmaster Tools). Next, click the button fetch and render do this for both versions, namely Desktop and Mobile.
After you do the above steps, the results will appear in the bottom line. Click on it and it will show you what users can see and what Googlebot can see when your site loads.
If you see a difference between the two screenshots, then this means that Googlebot cannot access the CSS / JS files. It will also show links to CSS and JS files that Google can’t access.
You can also find a list of blocked resources under the menu Google Indexs »Blocked Resources.
Clicking on each resource displayed will display a link to the actual resource that Googlebot cannot access. Most of it will focus on CSS styles and JS files plus a WordPress plugin or a WordPress theme.
Next, what you need to do is to edit your site’s robots.txt file, where the robots.txt file is a place to control all the file settings that can be accessed or files that are blocked.
You can edit the robots.txt file by logging into your hosting control panel or by using FTP. The robots.txt file will reside in your site’s root directory.
Find files robots.txt on a WordPress site using an FTP client
If you use SEO plugin by Yoast, then you can edit the robots.txt file from within your WordPress admin area. Just go to the page SEO »Tools and then click File Editor.
You will most likely notice that in the robots.txt file access to some of the WordPress directories is disallowed like this:
User-agent: * Disallow: /wp-admin/ Disallow: /wp-includes/ Disallow: /wp-content/plugins/ Disallow: /wp-content/themes/
Now you need to remove the line of code blocking Google’s access to CSS or JS files on the front-end of your site. Usually these files are located in the plugins or themes folder. You may also need to delete Disallow: / wp-includes /, many WordPress themes and plugins can call scripts located in the wp-includes folder, such as jQuery.
Some users may notice that their robots.txt file is empty or doesn’t even exist. If Googlebot doesn’t find the robots.txt file, it will automatically be able to access and index all your WordPress files.
If you see your robots.txt file is empty but the webmaster tools still has a warning “Googlebot Cannot Access CSS and JS files“, This is most likely your hosting provider blocking access to the default WordPress folder. You can override this in robots.txt to give googlebot access to the blocked folders.
User-agent: * Allow: /wp-includes/js/
Once you are done, save your robots.txt file. Visit the fetch as Google settings again at Search Console You, and click the fetch and render button. And see the results, of course you will see the similarities between what visitors and Googlebot see.
I hope this article helped you to solve the ‘Googlebot cannot access CSS and JS files’ error or problem on your WordPress site. Good luck and good luck. 🙂