should robots.txt files exclude css folders?

Generally, there's no compelling reason to block search engines from accessing CSS files through the robots.txt file. In fact, it's recommended that you allow search engines to access your CSS files. Here's why:

1. Rendering and Page Layout:

Google and other search engines are capable of rendering pages similar to how browsers do. They use CSS to understand how a page is presented to users. Blocking CSS could prevent search engines from fully understanding your page, potentially affecting how it's indexed and ranked.

2. Avoiding Cloaking:

Search engines want to ensure that users are presented with the same content as their crawlers. If search engines can't access the CSS, they might not be able to confirm that the visual representation of the page (as seen by users) matches the content their crawlers see. This could be misconstrued as cloaking, which is against Google's Webmaster Guidelines.

3. Mobile-Friendliness:

Search engines like Google use mobile-friendliness as a ranking factor. To determine this, they need to access CSS to see how a page renders on mobile devices. Blocking access to CSS can prevent search engines from determining if a page is mobile-friendly.

4. Potential Impact on Rankings:

As mentioned above, if search engines can't fully understand the content and layout of your page due to blocked CSS files, it might affect your site's search rankings.

5. Clear Communication:

Allowing access to CSS (and JavaScript files) ensures that you're giving search engines all the resources they need to understand and rank your content correctly.

Exceptions: While the general recommendation is to allow search engines to access CSS, there might be very specific scenarios or reasons to block certain files. However, these would be exceptions rather than the rule.

If you decide to block any resource, ensure that it's a deliberate decision and that you're aware of the potential implications. Always recheck the robots.txt configuration and ensure that important resources required for rendering and understanding your website are accessible to search engines.

Google Search Icon


Which folders should a robots.txt file exclude?

The folders and paths you choose to exclude in a robots.txt file will depend on the nature of your website and its content. However, there are some common directories and paths that many websites choose to exclude for various reasons.

Commonly Excluded Folders/Paths:

  1. Admin Areas:

    • e.g., /admin/, /wp-admin/, /backend/
    • These are sensitive areas of a site where administrative tasks are carried out. They are typically of no value to search engines and are best kept private.
  2. Core System Files:

    • For content management systems (CMS) like WordPress, directories like /wp-includes/ or /core/ might be excluded.
  3. Temporary or Staging Directories:

    • e.g., /temp/, /tmp/, /staging/
    • Directories used for testing, staging, or temporary storage usually don't need to be indexed.
  4. Private User Areas:

    • e.g., /user/, /account/, /dashboard/
    • Areas of your website where users manage their personal accounts or data.
  5. Search Results Pages:

    • URLs generated by internal site search functions. These can lead to duplicate content issues.
    • e.g., /search/, /query/
  6. Plugin and Theme Assets:

    • Depending on the CMS you use, you might decide to block certain plugin or theme directories, especially if they expose information you don't want public. However, be cautious not to block assets that affect page rendering for search engines.
  7. Utility Scripts:

    • e.g., /cgi-bin/, /scripts/
    • Directories containing scripts that are not meant to be accessed directly.
  8. Duplicate Content:

    • If you have print versions of your pages or other forms of content that can be seen as duplicate, it's wise to block them.
    • e.g., /print/, /pdf-version/
  9. Data and Configuration Files:

    • Files like .env, .git, .sql, or other configuration and data files that should not be publicly accessible or indexed.

Important Notes:

  • Always Test: Before making any changes to your robots.txt file, test the changes to ensure you aren't accidentally blocking important parts of your site. Google Search Console offers a robots.txt Tester tool that can be quite useful.

  • No Security Tool: Remember, robots.txt is not a security measure. Ethical search engines will obey it, but malicious bots can ignore it. If you need to secure a directory or file, use proper server-side security measures.

  • Specify User-agents: In your robots.txt file, you can specify directives for specific crawlers (user-agents) or use the wildcard * to target all crawlers.

  • Avoid Blocking CSS/JS: As mentioned earlier, it's generally a good idea to allow search engines to access your CSS and JavaScript files to understand and render your pages accurately.

Lastly, while the above gives a general idea, the specific folders and paths you choose to block or allow should be tailored to your website's structure and content. Regularly review and update your robots.txt file as your site evolves.

Keyboard Layout

Why Do I See Loops of /js/js/js/js On on my Sites?

Seeing looping patterns like /js/js/js/js/ in tools like Ahrefs or other SEO crawlers can be indicative of a configuration or link structure issue on your website. This phenomenon typically arises from a relative path issue in your website's code or some misconfiguration. Here's why this might be happening and how you can address it:

1. Relative vs. Absolute URLs:

One of the most common reasons for such loops is the use of relative URLs instead of absolute URLs.

For instance, consider a JavaScript link implemented as:

<script src="js/script.js"></script>

If this code is placed on a page with the URL, a crawler would interpret the script's URL as If the same relative URL is somehow present within that script or interpreted as a link, the crawler might then think there's another layer, leading to, and so on.

Using absolute paths can help avoid this confusion:

<script src="/js/script.js"></script>

2. Misconfigured Redirects:

Check if there are any redirect rules in place (e.g., in your .htaccess file, NGINX config, or CDN settings) that might be causing such looping patterns.

3. Broken Link Structures:

Ensure that there are no broken internal links or incorrectly referenced assets that might lead crawlers down these looping paths.

4. Third-party Plugins/Themes:

Sometimes, third-party plugins or themes, especially in CMS systems like WordPress, might have bugs or quirks that result in such patterns. Ensure that all plugins/themes are updated and check if disabling them one by one resolves the issue.

5. Check Canonical URLs:

Ensure that canonical URLs are correctly set up. A misconfigured canonical link can sometimes cause crawlers to interpret page hierarchies incorrectly.

6. Crawler Behavior:

Some crawler configurations might interpret or handle links differently. While this is less likely, it's worth checking Ahrefs settings or reaching out to their support to see if there's any known issue or behavior causing this.

How to Address the Issue:

  1. Identify the Source: First and foremost, identify where these looping paths originate. You can use the SEO tool itself to trace back where these URLs are first discovered.

  2. Audit Your Site: Tools like Screaming Frog SEO Spider can help you crawl and analyze your site locally to spot and fix such issues.

  3. Update URLs: As mentioned, switch to using absolute paths where appropriate to avoid ambiguities.

  4. Implement Proper Redirects: Ensure that any redirection rules are correctly set up and not leading to looping paths.

  5. Check Robots.txt: While it's not a solution to the root problem, you can use the robots.txt file to disallow crawling of these problematic patterns as a temporary measure.

  6. Monitor and Test: After making changes, monitor your site's crawl reports to see if the issue persists.

If you've tried troubleshooting and still can't resolve the issue, it might be helpful to consult with a web developer or an SEO specialist who can take a closer look at your site's configuration and structure.

Google Search

Should Search Engines Be Crawling a Web Site's Image Folders?

Search engines crawling and indexing images from a website can be both beneficial and problematic, depending on the context. Here's a breakdown of the pros and cons:

Pros of Allowing Search Engines to Crawl Website Image Folders:

  1. Image Search Visibility: Images from your site can appear in image search results (e.g., Google Images). This can drive additional traffic to your site, especially if you have unique or high-quality images.

  2. Enhanced Page Understanding: By crawling images, search engines gain a better understanding of the content and context of your page. This is particularly true if your images have descriptive file names and ALT text.

  3. Rich Results: In some cases, images can help your site appear as rich results in the SERPs (search engine results pages), enhancing visibility and click-through rates.

Cons of Allowing Search Engines to Crawl Website Image Folders:

  1. Bandwidth Consumption: If you have a lot of high-resolution images, search engine crawlers can consume significant bandwidth, which might slow down the site for actual users or increase hosting costs.

  2. Copyright Concerns: If you have proprietary images, there's a risk that they could be more easily found and potentially used without permission by others.

  3. Irrelevant Traffic: Image search can sometimes lead to irrelevant traffic. Users might land on your site through an image search without being interested in the actual content or products/services you offer.

  4. Sensitive Images: If you have images that you don't want to be public or indexed (e.g., private event photos, unpublished product images), it's essential to block them from crawlers.

What Should You Do?

The decision to allow or disallow search engines from crawling your image folders should be based on your specific circumstances:

  1. Default to Allow: In most cases, allowing search engines to index your images is beneficial, especially for public-facing, content-rich sites where image search might drive relevant traffic.

  2. Use Robots.txt: If you decide to block search engines from crawling specific image folders, you can use the robots.txt file. An example directive:

    User-agent: * Disallow: /path-to-your-image-folder/
  3. Use Image Sitemaps: If you want search engines to prioritize specific images, consider creating an image sitemap. This helps search engines discover images that might be loaded by JavaScript or located in other less-crawlable locations.

  4. Optimize Images: If you allow crawling, ensure your images are optimized for the web (compressed, appropriately sized, with descriptive filenames and ALT attributes). This not only helps with SEO but also with site performance.

  5. Consider Copyright: If you're worried about image theft, you might add watermarks to proprietary images or use other methods to deter unauthorized use. Remember, though, that blocking crawlers from accessing images doesn't prevent a determined individual from accessing and downloading them if they're viewable on the site.

In summary, whether search engines should crawl website image folders depends on the specific goals and content of the site. However, in many cases, allowing image crawling can be beneficial for SEO and traffic generation. 



Add comment