Trailing slash consistency
Issue No: 16
Category: page seo basics
Issue type: Warning
Priority: STANDARD
Description
Verify that the site applies one consistent trailing slash policy so duplicate URL variants do not split crawl and indexing signals.
How do we capture it
- Fetch page URL and capture final URL after redirects.
- Generate alternate slash variant of final URL path:
- If path ends with slash, build non-slash variant.
- If path does not end with slash and is not root, build slash variant.
- Optionally perform lightweight HEAD/GET request on alternate variant to inspect redirect behavior and status code.
- Compare canonical URL, final URL, and alternate variant response:
- Determine if one variant consistently redirects to the other.
- Detect cases where both return indexable content without canonical consolidation.
- Treat root path separately (
/) as policy-compliant baseline. - Record observed policy as slash-preferred, no-slash-preferred, mixed, or unknown.
- Constraint: this validation uses HTTP responses and raw URL comparisons only.
What to store
| Field | Type | Comment |
|---|---|---|
| page_url TEXT | TEXT | Requested URL before redirects. |
| final_url TEXT | TEXT | Final resolved URL for analyzed page. |
| final_path_has_trailing_slash BOOLEAN | BOOLEAN | Whether final URL path ends with slash. |
| alternate_variant_url TEXT | TEXT | Computed opposite trailing slash URL variant. |
| alternate_variant_status_code INTEGER | INTEGER | Status code returned by alternate variant request. |
| alternate_redirects_to_final BOOLEAN | BOOLEAN | Whether alternate variant redirects to final URL. |
| canonical_url TEXT | TEXT | Canonical URL extracted for slash-policy comparison. |
| trailing_slash_policy TEXT | TEXT | Detected policy label: slash, no-slash, mixed, unknown. |
| trailing_slash_is_consistent BOOLEAN | BOOLEAN | Whether observed behavior is policy-consistent. |
| trailing_slash_diagnostics JSONB | JSONB | Detailed evidence and comparison outcomes. |
Condition for trigger
This audit triggers when slash policy is mixed or duplicate variants are indexable.
-
Trigger Rule 1: Mixed Slash Policy
- Target Field:
trailing_slash_is_consistent - Evaluation Logic:
trailing_slash_is_consistent = FALSE - Severity: SUGGESTION
- Diagnostic Message: "Trailing slash behavior is inconsistent across URL variants."
- Target Field:
-
Trigger Rule 2: Alternate Variant Not Consolidated
- Target Field:
alternate_redirects_to_final - Evaluation Logic:
alternate_variant_url IS NOT NULL AND alternate_redirects_to_final = FALSE - Severity: SUGGESTION
- Diagnostic Message: "Trailing slash variant does not redirect to preferred URL version."
- Target Field:
-
Trigger Rule 3: Canonical Conflicts With Final URL Style
- Target Field:
canonical_url - Evaluation Logic:
canonical_url IS NOT NULL AND trailing_slash_is_consistent = FALSE - Severity: SUGGESTION
- Diagnostic Message: "Canonical URL style conflicts with observed trailing slash behavior."
- Target Field:
Sources
- Google Duplicate URL Consolidation: https://developers.google.com/search/docs/crawling-indexing/consolidate-duplicate-urls
- RFC 3986 URI Generic Syntax: https://www.rfc-editor.org/rfc/rfc3986
- MDN URL API: https://developer.mozilla.org/en-US/docs/Web/API/URL
Long description
Trailing slash variants often represent technically different URLs to crawlers. If both variants are accessible and indexable, crawl budget and ranking signals can be diluted across duplicates. A consistent redirect and canonical strategy prevents ambiguity and simplifies internal linking, sitemap generation, and log analysis.
Common failure scenarios checked by the crawler:
- Both slash and non-slash variants return 200 without consolidation.
- Canonical points to one style while redirects prefer another.
- Site behavior differs by directory or template.
- Alternate variant produces soft duplication with no canonical alignment.
How to Fix
Define one trailing slash standard for indexable pages and enforce it with consistent permanent redirects. Align canonical tags, internal links, and sitemap URLs to the same standard. Regularly crawl slash/non-slash pairs to verify policy compliance remains stable.