Fix double-slash redirect paths in CI builds #7343
Open
+4
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix: Double-Slash Redirect Paths on GitHub Pages Deployments
Summary
This PR fixes a critical redirect bug in
gatsby-node.jsthat generates malformed double-slash (//) paths during GitHub Pages (CI=true) builds. These malformed redirects break trailing-slash navigation across the site and negatively impact SEO.The issue affects all dynamically created pages and only manifests in production GitHub Pages deployments, making it difficult to detect during local development.
Problem Description
When
CI=true, Gatsby creates redirects intended to normalize trailing-slash URLs. However, the current logic incorrectly prepends/to paths that already start with/, producing invalid redirect paths.Example
Given a valid slug:
The current redirect logic generates:
This results in broken redirects for URLs with trailing slashes.
Affected Areas
File:
gatsby-node.jsLines:
onCreatePage)envCreatePage)Deployment Target: GitHub Pages (
CI=true)Pages Impacted:
(1000+ pages total)
Root Cause
All slugs generated in
onCreateNodeare explicitly prefixed with/:Redirect creation logic incorrectly assumes
pathandmatchPathdo not start with/.This mismatch causes double-slash paths (
//) in redirect rules.Reproduction Steps
Production Preview
Open any PR in the
layer5repositoryWait for the GitHub Pages preview build
Open any dynamic page (blog, event, etc.)
Manually add a trailing slash to the URL
Example:
/blog/meshery/my-post/Observe broken or incorrect redirect behavior
Local
Inspect generated redirect HTML files in
public/and note double-slash paths in meta refresh tags.Fix Implemented
Removed the extra leading
/when constructing redirect paths.envCreatePage(lines 65–70)onCreatePage(lines 42–46)Impact After Fix
Why This Matters
This fix prevents widespread broken navigation and SEO degradation across the site’s primary production deployment. It ensures consistent, predictable URL behavior for users, contributors, and search engines alike.
Checklist
Please review and merge to restore correct redirect behavior on GitHub Pages.