I have enabled `statistics` module and now the google bot is saying

"Blocked Resources > http://www.tundriyal.com > /core/modules/statistics/statistics.php
These pages use this blocked resource. If Googlebot can't access important resources on your page, the page might be indexed incorrectly."

More information of blocked resource can be found at https://support.google.com/webmasters/answer/6153277

This is blocking my site from getting crawled on search engines (https://www.drupal.org/project/drupal/issues/2883776#comment-12238819).

CommentFileSizeAuthor
#7 2883776-7.patch352 byteswim leers

Comments

RavindraSingh created an issue. See original summary.

cilefen’s picture

Do you know for a fact this is blocking your site from being crawled? It seems an ordinary notice.

erwangel’s picture

I have this warning with all 7.x stable as well (currently 7.56). Although statistics is enabled across all pages of my site and a lot or most of them look indexed by google, several (1400 of 27000) are listed as blocked because of statistics.php in "blocked resources" of Search console (aka Google webmaster tools).

websiteworkspace’s picture

Is the bug described in this thread the source of the constant:


"page not found" 

http://{site}/core/modules/statistics/statistics.php

warning/errors in the recent log messages for nearly every URL on any D8 site that enables core statistics?

ykoech’s picture

***********

timmillwood’s picture

Do we need to specifically disallow the full path in robots.txt? we already have Disallow: /core/ so this should be covered, right?

wim leers’s picture

Status: Active » Needs review
StatusFileSize
new352 bytes

#6: Isn't that exactly what's causing this? I think we need

Allow: /core/modules/statistics/statistics.php
wim leers’s picture

Ironically, we also have #2433955: Statistics - Exclude bots (search engines, etc.).

Which is true? What's the behavior we want?

ricovandevin’s picture

I guess the desired behavior is that the resource (/core/modules/statistics/statistics.php) is available to crawlers but it should not record the view.

ricovandevin’s picture

Status: Needs review » Reviewed & tested by the community

The patch from #6 will work to solve the 'blocked resource' issue. We will need to block recording of the hits of crawlers to have more reliable statistics but that is worked on in #2433955: Statistics - Exclude bots (search engines, etc.).

ricovandevin’s picture

Version: 8.2.x-dev » 8.6.x-dev

Aligned version with release cycle.

alexpott’s picture

Status: Reviewed & tested by the community » Needs review

Hmmm. Don't we need to do #2433955: Statistics - Exclude bots (search engines, etc.) first? At the moment hits are not recorded by bots because we block the resource right? Applied this will change that.

wim leers’s picture

#7 will only work while you have not moved statistics.php elsewhere.

I wonder if the solution lies in X-Robots-Tag: https://developers.google.com/search/reference/robots_meta_tag

ricovandevin’s picture

I don't see a solution in X-Robots-Tag (yet). As far as I can find out now there is no directive telling a bot to stop crawling a resource. You can tell a bot not to include the resource in a search index but that will not prevent the bot from requesting the resource (and thus recording views in case of /core/modules/statistics/statistics.php). But... I might be overlooking something. :-)

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

xmacinfo’s picture

Issue summary: View changes

What is the correct approach to make sure that the core statistics module works again?

The statistics counter is frozen to an old value and won’t update (see comment #2883776-4: /core/modules/statistics/statistics.php These pages use this blocked resource. If Googlebot can't access important resources on your page, the page might be indexed incorrectly.). This fills the watchdog with errors.

xmacinfo’s picture

Status: Needs review » Needs work

Editing the robots.txt file to allow the not found URL does not repair the statistics.

Allow: /core/modules/statistics/statistics.php

berdir’s picture

I don't understand why we should allow crawlers to access this, they shouldn't.

This isn't related to fixing a frozen value, the value is supposed to update once per our but I suppose the page cache gets in the way as it doesn't respect that. But that has nothing to do with this issue.

xmacinfo’s picture

I searched for an issue trying to fix the "page not found" watchdog error and found this issue.

Looks like both Drupal statistics module and Google cannot find the page (/core/modules/statistics/statistics.php) and update the statistics using the Statistics module.

If this is not related, I will open a new issue.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

devoleksiy’s picture

How do I apply this patch using composer, the code I use drupal/core I see an error error.

How to apply a patch to web root files?

"extra": {
        "composer-exit-on-patch-failure": true,
        "patchLevel": {
            "drupal/core": "-p2"
        },
        "drupal-scaffold": {
            "file-mapping": {
                "[web-root]/robots.txt": false
            },
			"locations": {
                "web-root": "web/"
            }
        },
        "installer-paths": {
            "web/core": ["type:drupal-core"],
            "web/libraries/{$name}": ["type:drupal-library"],
            "web/modules/contrib/{$name}": ["type:drupal-module"],
            "web/profiles/contrib/{$name}": ["type:drupal-profile"],
            "web/themes/contrib/{$name}": ["type:drupal-theme"],
            "drush/Commands/contrib/{$name}": ["type:drupal-drush"]
        },
        "patches": {
          "drupal/core": {
            "Fixed robot.txt": "https://www.drupal.org/files/issues/2883776-7.patch"
          }
        }
    }

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Status: Needs work » Postponed

Statistics is approved for removal. See #3266457: [Policy] Deprecate Statistics module in D10 and move to contrib in D11

This is now Postponed. The status is set according to two policies. The Remove a core extension and move it to a contributed project and the Extensions approved for removal policies.

It will be moved to a contributed Statistics project once the project is created and the Drupal 11 branch is open.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Project: Drupal core » Statistics
Version: 11.x-dev » 1.0.0-beta1
Component: statistics.module » Code
Status: Postponed » Needs work