Skip to content

core/canonical: flag non-home pages whose canonical points at the homepage #1685

Description

@nc9

Problem

A template that hard-codes the canonical URL to the site root tells search engines that every page is a duplicate of the homepage. The pages then drop out of the index. core/canonical checks that a canonical exists and is valid, but it passes this case because the URL is well formed.

Proposal

Add a canonical-to-homepage check to core/canonical. It fails when a page that is not the homepage declares the site root as its canonical.

Acceptance Criteria

  • A page at any path other than the site root whose canonical resolves to the site root fails canonical-to-homepage as an error, and the finding shows the page URL and the canonical.
  • The homepage with a self-referencing canonical passes.
  • Root variants that the site treats as the homepage (trailing slash, /index.html, the www and non-www form of the same host) are not flagged for pointing at the root.
  • A locale homepage such as /en/ that canonicals to / is reported as a warning, not an error.
  • A page that redirects to the homepage is not flagged by this check.
  • The canonical from the Link header is treated the same as the tag.
  • Pages with a canonical to any other URL get the same result as before this change.
  • The docs page for core/canonical describes the new check.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementrulessize: S

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions