Googlebot无法访问CSS和JS文件

Googlebot cannot access CSS and JS files?

本文关键字:JS 文件 CSS 访问 Googlebot      更新时间:2023-09-26

收到google Search console warning - "Googlebot cannot access CSS and JS"

我的robots . txt

User-agent: *
Disallow: /_System
Disallow: /bcas-homepage-slider
Disallow: /css
Disallow: /fonts
Disallow: /images
Disallow: /js
Disallow: /Layouts
Disallow: /Medigap logos
Disallow: /POST-IMAGES
Disallow: /products
Disallow: /professional-specialities
Disallow: /_backups
Disallow: /thank-you
Disallow: /stylesheets
Disallow: /source
Disallow: /Report
Disallow: /new

如何删除此警告?

您需要编辑位于站点根目录下的robots.txt文件。无论哪里有一个"禁止"行,这意味着你要求谷歌机器人不要爬过这些目录。

只需要从robots.txt中删除以下内容

Disallow: /css
Disallow: /js

对于Joomla 3,这可能是最简单的解决方案。将其添加到默认robots.txt文件的末尾。

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

如果你想更具体一点,可以这样写:

User-agent: Googlebot
Allow: /plugins/ *.css
Allow: /plugins/*.js
Allow: /modules/ *.css
Allow: /modules/*.js

关于

早在2015年4月,我就根据Joomla 3发布的更新后的robots.txt文件修改了我的robots.txt文件。

:
Disallow: /media/
Disallow: /templates/

谷歌已经发出了新一轮的警告信息,似乎需要更多的访问权限。

查看需要解除封锁的最佳方法是登录网站管理员工具(又名"搜索控制台"),然后转到谷歌索引->被封锁的资源。这假设您的网站启用了搜索控制台。

看起来谷歌希望我现在解锁以下包含CSS和JS资源的文件夹:

Disallow: /components/
Disallow: /libraries/
Disallow: /modules/
Disallow: /plugins/

全面解决"Googlebot无法访问CSS和JS文件"问题,在这里描述

消息是什么意思?

这条消息是关于谷歌对响应式设计的新关注。

你的robots.txt文件告诉Google不要使用你的一些CSS和/或Javascript文件。

Google现在需要这些文件来测试你的移动站点友爱。没有他们,你的排名就会下降。我们覆盖几乎完全相同的问题发生在今年4月谷歌的"移动"项目上世界末日。"

解决方案是什么?

去谷歌的移动友好测试和检查你的网站。这是一个收到谷歌邮件的网站截图

值得庆幸的是,Google的测试人员提供了非常丰富的信息,并指出了这个特定网站的确切问题。robots.txt文件就是阻止Google访问它所需要的资源。

你可以找到被谷歌屏蔽的确切资源点击右侧的"显示资源"链接Google的测试人员将那里的文件与robots.txt进行比较确定哪些需要解除阻塞。

如何解决问题

解决方案将取决于您使用的CMS,因为每个平台将CSS和Javascript文件存储在不同的位置。

  • Joomla solution (OSTraining.com)
  • Drupal解决方案(jimbirh .ch)WordPress解决方案(petermahoney.net)