How to Fix “Googlebot cannot access CSS and JS files” Error in WordPress

How to Fix “Googlebot cannot access CSS and JS files” Error in WordPress

Are you facing Googlebot cannot access CSS and JS files warning in Google webmaster tools account for your WordPress site? This error occurs when you try to increase WordPress security. We will help you to fix this issue with the guide of two things.

  • Check Robots.txt File
  • Check WordPress Security plugin configuration

Is the Google Search Console showing you the “Googlebot cannot access CSS and JS files” error in your WordPress website? This error message is mostly sent to you as an email or indicated on your Google Search Console dashboard. It usually comes with links to instructions showing you how you can fix the issue, but sometimes the instructions may be a little complicated. In this article, I will show you how to fix the “Googlebot cannot access CSS and JS files” error in WordPress.

How to Fix “Googlebot cannot access CSS and JS files” Error in WordPress

Why Does Google Need Access To Your CSS and JS Files?

Google uses the CSS and JavaScript files to analyze the performance of a website and check if the website offers a user-friendly experience, thereby determining its ranking. Googlebot also uses CSS and JavaScript files to analyze if the website is mobile-friendly.

Blocking the Googlebot from accessing the CSS and JS files on your website is not a good idea, but sometimes a security plugin or you may accidentally block them.

This could block the Googlebot from indexing the CSS and JS files, affecting the SEO of your website and reducing your site’s ranking.

Now let’s see how to fix the “Googlebot cannot access CSS and JS files” error in WordPress.

How to Fix “Googlebot Cannot Access CSS and JS Files” 

First, you have determined which of the files on your site the Google bots are unable to access. You can do this using the Google Search Console tools.

Simply log into the Google Search Console dashboard, then on the menu at the left-hand side of the page, click Crawl and select Fetch as Google. This will display your website to you as it is seen by the Googlebot.

Now click on Fetch and Render, and then wait for a few seconds. Two screenshots will appear showing you what the user sees and what Googlebot sees when they visit your site’s homepage.

Why Google Needs Access to CSS and JS Files?

Google is focused on giving better rankings to user friendly websites – sites that are fast, have good user experience, etc. In order to determine the user experience of a website, Google needs access to be able to visit the site’s CSS and JavaScript files.

By default WordPress does not block search bots from accessing any CSS or JS files. However some site owners may accidentally block them while trying to add extra security measures or by using a WordPress security plugin.

This restricts Googlebot from indexing CSS and JS files which may affect your site’s SEO performance.

Having said that, let’s see how we can locate these files and unblock them.

How to Give Google Access to Your CSS and JS Files

First you need to know which files Google is unable to access on your website.

You can see how Googlebot sees your website by clicking on Crawl » Fetch as Google in Google Search Console (formerly Webmaster Tools). Next, click on fetch and render button (you want to do this for both Desktop and Mobile).

How to Fix “Googlebot cannot access CSS and JS files” Error in WordPress

Once fetched, the result will appear in a row below. Clicking on it will show you what a user sees and what the Googlebot sees when it loads your site.

How to Fix “Googlebot cannot access CSS and JS files” Error in WordPress

If you notice any difference between the two screenshots, then this means that Googlebot was not able to access CSS/JS files. It will also show you the links of CSS and JS files it was unable to access.

You can also find a list of these blocked resources under Google Index » Blocked Resources.

How to Fix “Googlebot cannot access CSS and JS files” Error in WordPress

Clicking on each resource will show you the links to actual resources that cannot be accessed by Googlebot.

Most of the time, these are CSS styles and JS files added by your WordPress plugins or theme.

Now you will need to edit your site’s robots.txt file which is what controls what Google bot sees.

You can edit it by connecting to your site using an FTP client. The robots.txt file will be in your site’s root directory.

How to Fix “Googlebot cannot access CSS and JS files” Error in WordPress

If you are using Yoast SEO plugin, then you can edit robots.txt file from within your WordPress admin area. Simply go to SEO » Tools page and then click on File Editor.

How to Fix “Googlebot cannot access CSS and JS files” Error in WordPress

You will most likely see that your site has disallowed access to some WordPress directories like this:

User-agent: *
Disallow: /wp-admin/
Disallow: /wp-includes/
Disallow: /wp-content/plugins/
Disallow: /wp-content/themes/

Now you need to remove the lines that are blocking Google’s access to CSS or JS files on your site’s front-end. Typically these files are located in the plugins or themes folders. You may also need to remove wp-includes, many WordPress themes and plugins may call scripts located in wp-includes folder, such as jQuery.

Some users may notice that their robots.txt file is either empty or does not even exist. If Googlebot does not find a robots.txt file, then it automatically crawls and index all files.

Then why are you seeing this warning?

On rare occasions, some WordPress hosting providers may proactively block access to default WordPress folders for bots. You can override this in robots.txt by allowing access to blocked folders.

User-agent: *
Allow: /wp-includes/js/

Once you are done, save your robots.txt file. Visit the fetch as Google tool, and click on fetch and render button. Now compare your fetch results, and you will see that most blocked resources issue should disappear now.

Leave a Reply

Your email address will not be published. Required fields are marked *