Skip to content

How to fix "Googlebot cannot access CSS and JS files" error in WordPress?

In the world of SEO, it is extremely important that Google robots have full access to all the important files on your website, such as JavaScript (JS) and Cascading Style Sheets (CSS) files. Google uses these files to understand and evaluate the quality of your site, which directly affects your rankings.

However, some WordPress users encounter a bug that prevents Googlebot from accessing CSS and JS files. This article describes how to fix this error so that your site can be properly indexed and ranked by Google.

1. Check the robots.txt file

The first step in solving this problem is to check the robots.txt file on your website. The robots.txt file is a simple list of directives that tell web crawlers what parts of a page to index and what parts to skip.

Open the robots.txt file and make sure there are no lines blocking access to the CSS or JS files. If so, remove them.

Your WordPress site should have the following settings in its robots.txt file to allow Googlebot to access CSS and JS files:

User-agent: Googlebot Allow: .js Allow: .css

2. SEO browser settings

Some SEO plugins such as Yoast SEO, give the user control over how robots search their website. If you use such a plugin, make sure its settings do not block access to CSS and JS files.

3. Use the plugin

You can also use dedicated plugins that help you manage the robots.txt file on your WordPress website. One such tool is “Virtual Robots.txt”. After installing and activating this plugin, you will be able to edit the robots.txt file directly from your WordPress dashboard.

4. Use the Google Search Console tool

Google Search Console is a powerful tool that will help you understand how Google sees your website. You can use the “robots.txt Tester” feature in Google Search Console to check whether Googlebot can access CSS and JS files.

However, remember that changes to the robots.txt file on your site may take up to several days to be noticed by Google. That's why it's important to check Google Search Console regularly and make sure everything is working properly.

5. Correct server settings

In some cases, the problem may be related to the server settings. If the issue still persists after following the steps above, you may need to consult your hosting provider or server specialist.

To summarize, fixing the "Googlebot cannot access CSS and JS files" error in WordPress requires checking several different things, from the robots.txt file, to SEO plugin settings, to server configuration. Remember that regularly monitoring your page's indexing status in Google Search Console is key to maintaining good SEO performance.

Check out the offer of 1500+ Premium WordPress plugins and themes!