Skip to content
FunnelGuard

Fix guide by FunnelsGuard

robots.txt blocks CSS or JS: how to find and fix it

SEO-003Medium impactOther toolBy FunnelGuardPublished Updated
On this page

What this issue is

robots.txt is a plain text file at the root of your site that tells crawlers which URLs they may fetch. Pages are not just HTML. They also load stylesheets (CSS), scripts (JS), fonts and sometimes JSON data from other paths.

Googlebot renders pages much like a browser does. If a rule such as Disallow: /assets/ or Disallow: /wp-includes/ covers files the page needs, Google can't load them. The page it sees may look unstyled, miss content that scripts add, or hide menus and links.

This often happens by accident. Old SEO advice said to hide script and theme folders, and some plugins or developers still add those rules. Files served from a CDN or another domain follow the robots.txt of that domain, which is easy to forget.

Example of rules that cause the problemtext
User-agent: *
Disallow: /wp-includes/
Disallow: /wp-content/themes/
Disallow: /assets/js/
Disallow: /static/

Why it costs you leads or sales

If Google can't render a page properly, it may misread what the page is about. Text added by JavaScript, product details, reviews or internal links can be missed. A layout that looks broken to Google may also be judged as not mobile friendly.

The result is weaker rankings or pages that are indexed with thin content. That means fewer visitors finding your landing pages and product pages from search, and fewer leads and sales from them. The impact is usually medium: your site still works for people, but search visibility quietly suffers.

How blocked CSS or JS hurts a search visit
  1. Googlebot fetches HTMLPage HTML loads fine
  2. CSS/JS requestedrobots.txt says Disallow
  3. Page renderedUnstyled or missing content
  4. Ranking and clicksWeaker understanding of the page

Googlebot fetches the HTML, but the blocked files stop it seeing the real page.

How to check if your site has it

Find blocked resources
  1. Open your robots.txt

    Visit https://yourdomain.com/robots.txt and look for Disallow lines covering folders like /wp-includes/, /wp-content/, /assets/, /static/, /js/, /css/ or file patterns such as *.js and *.css.

  2. Inspect a key URL in Google Search Console

    Paste a landing page into the URL Inspection tool, click Test Live URL, then View Tested Page and open the Screenshot and More Info tabs. Look at the list of page resources and any marked as blocked by robots.txt.

  3. Compare the screenshot to your real page

    If the rendered screenshot looks unstyled, has missing sections or hidden menus, a blocked file is the likely cause.

  4. Check third-party hosts

    Open your browser dev tools, go to the Network tab and note which domains serve your CSS and JS (a CDN, for example). Visit /robots.txt on each of those hosts too.

  5. Test specific files

    In Search Console, open Settings, then robots.txt report, to confirm Google's fetched version of the file. Use the URL Inspection tool on a script URL to see if it's blocked.

How to fix it

The fix is the same everywhere: stop disallowing files that pages need to render. Remove the rule, or narrow it so CSS, JS and fonts stay crawlable. Where the file lives and how you edit it depends on your platform.

Edit robots.txt by platform
  1. Find where robots.txt comes from

    It may be a physical file in the site root, a virtual one WordPress generates, or one managed by an SEO plugin (for example in Yoast SEO under Tools, File editor, or Rank Math under General Settings, Edit robots.txt).

  2. Remove the blocking rules

    Delete lines such as Disallow: /wp-includes/ or Disallow: /wp-content/themes/. Keep Disallow: /wp-admin/ with Allow: /wp-admin/admin-ajax.php if you use it.

  3. Check for security or cache plugins

    Some plugins write their own rules. If the line returns after you save, look in those plugins' settings.

If you must block a folder, allow its assetstext
User-agent: *
Disallow: /private-app/
Allow: /private-app/*.css
Allow: /private-app/*.js
robots.txt before and after

Before

  • Disallow: /wp-includes/ and /assets/js/
  • Google screenshot shows an unstyled page
  • URL Inspection lists blocked resources

After

  • Asset rules removed or narrowed with Allow
  • Google screenshot matches the real page
  • No resources blocked by robots.txt

How to confirm it's fixed

Confirmation checks
  • Open /robots.txt in a browser and confirm the Disallow lines are gone
  • In Search Console, check Settings, robots.txt report shows the new version fetched
  • Run URL Inspection, Test Live URL on a key page and confirm no resources are blocked by robots.txt
  • Compare the rendered screenshot with the live page
  • Repeat the check on a page template of each type: home, landing, product, blog
  • Request indexing for your most important pages

How to prevent it happening again

Prevention habits
  • Keep robots.txt in version control or note every edit and who made it
  • Never copy a robots.txt from another site or an old guide without reading each line
  • Block pages you don't want crawled, not the folders that hold code and styles
  • Re-check robots.txt after theme changes, migrations, CDN changes and plugin installs
  • Check the robots.txt of any separate host that serves your assets
  • Review the URL Inspection rendered screenshot after major releases

How FunnelGuard handles this

FunnelGuard does not check this yet. Spotting CSS or JS blocked by robots.txt is a possible future check, but today it isn't part of the product.

What FunnelGuard does do is run your real customer journeys on a schedule, such as lead forms, checkouts and booking buttons, and check each step and the tracking hits. If a broken page stops a journey working for the robot visitor, you get an alert with a screenshot. That covers what real visitors experience, not what Googlebot can fetch.

To watch for this issue yourself, use the Search Console robots.txt report and URL Inspection tool after changes, and review your robots.txt whenever a theme, plugin or CDN changes. A free read-only website audit from FunnelGuard is also available, and the Free plan covers 1 site and 2 journeys with daily checks and no card.

Frequently asked questions

Questions people ask

Why does Google say my page resources are blocked by robots.txt?

A Disallow rule in robots.txt matches the URL of a CSS, JS or font file your page loads. Google obeys that rule and doesn't fetch the file. Find the matching line in your robots.txt, or in the robots.txt of the host serving the file, and remove or narrow it.

Should I block CSS and JavaScript in robots.txt?

No, not if pages need those files to display. Google renders pages like a browser, and blocked files can leave it with a broken or incomplete view of your content. Block pages you don't want crawled instead of asset folders.

How do I allow Googlebot to crawl CSS and JS files?

Remove the Disallow lines that cover them. If you need to keep a folder blocked, add Allow rules such as Allow: /folder/*.css and Allow: /folder/*.js. For Google, the longer, more specific matching rule takes precedence.

How do I test whether Googlebot can render my page?

Use the URL Inspection tool in Google Search Console, click Test Live URL, then View Tested Page. Check the screenshot and the page resources list for anything blocked by robots.txt.

Does blocking CSS and JS hurt SEO rankings?

It can. If Google can't render a page properly, it may miss content, links or mobile layout, which can weaken how the page is understood and ranked. The effect varies by site and how much the page relies on those files.

Why is my robots.txt blocking wp-includes?

Older WordPress SEO advice and some default or copied robots.txt files include Disallow: /wp-includes/. Delete that line, and check SEO and security plugins that might add it back.

Do third-party scripts need to be allowed in my robots.txt?

Files hosted on another domain follow that domain's robots.txt, not yours. You can't change theirs, but widely used CDNs and script hosts normally allow crawling. If a file from your own CDN is blocked, edit the robots.txt on that host.

Can FunnelGuard tell me if robots.txt blocks my CSS or JS?

Not yet. This is a possible future check. FunnelGuard currently monitors your funnel journeys, tracking hits and lead delivery, so use Google Search Console to check robots.txt blocking.

Does FunnelGuard catch this?

Other tool

Needs a different kind of tool.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.