Skip to content

Latest commit

 

History

History
49 lines (38 loc) · 1.85 KB

File metadata and controls

49 lines (38 loc) · 1.85 KB

assert-canonicals

SEO deploy gate — fetch each URL and assert its canonical is present, singular, consistent, and correct, across both the HTML and the HTTP layer.

What it catches

  • HTML ≠ HTTP header<link rel="canonical"> says one thing, the Link: rel="canonical" response header says another. (CANONICAL_CONFLICT)
  • Wrong canonical — points at a different URL than expected (by default, not self-referential). (CANONICAL_MISMATCH)
  • No canonical at all — neither source present. (CANONICAL_MISSING)
  • More than one rel="canonical". (CANONICAL_MULTIPLE)
  • Unreachable URL — non-200 status. (CANONICAL_FETCH)

Usage

- uses: nimajafari/seo-ci/actions/assert-canonicals@v1
  with:
    urls: |
      https://www.example.com/products/widget
      https://www.example.com/blog/post -> https://www.example.com/blog/post/
    canonical-form: any   # trailing_slash | no_trailing_slash | any

By default each URL must be self-canonical. Use url -> expected to assert a deliberate cross-URL canonical.

Inputs

Input Default Description
urls — (required) URLs to check; url or url -> expected per line (JSON array accepted).
canonical-form any Trailing-slash policy for comparison.
user-agent Googlebot User-agent used for fetching.
strict false Treat warnings as errors.
report-path "" Write the JSON report to this path.

Outputs

passed, errors, warnings, notices, report — see the top-level README.

Caveat: A starting point, not a drop-in guarantee. Your canonical rules (self vs cross-URL, trailing-slash policy) are specific to your site. And never serve crawlers a different canonical than users — cloaking violates Google's policies.