豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

refactor(gatsby-node): simplify page creation logic and remove redundant redirects#7634

Open
Abmarne wants to merge 3 commits intolayer5io:masterfrom
Abmarne:master
Open

refactor(gatsby-node): simplify page creation logic and remove redundant redirects#7634
Abmarne wants to merge 3 commits intolayer5io:masterfrom
Abmarne:master

Conversation

@Abmarne
Copy link
Copy Markdown
Contributor

@Abmarne Abmarne commented Apr 15, 2026

Fix: #7606

The problem was in gatsby-node.js where the code was creating redirects from paths with trailing slashes to paths without trailing slashes when running in CI mode. This conflicted with the trailingSlash: "never" configuration in gatsby-config.js

What I Changed

I removed the redirect creation logic in the envCreatePage function (lines 56-72) that was causing the conflicts. The code was attempting to create redirects like:

  • From: /learn/learning-paths/mastering-kubernetes-for-engineers/
  • To: /learn/learning-paths/mastering-kubernetes-for-engineers

Since your Gatsby configuration already specifies trailingSlash: "never", these redirects were redundant and caused warnings because Gatsby was creating both the pages and the redirects for the same paths.

Result

The build should now be clean without the warnings about routes matching both page and redirect. The pages will continue to work correctly without trailing slashes as configured in your gatsby-config.js.

The fix has been applied successfully. The build warnings about conflicting page and redirect routes should now be resolved. The change removes the redundant redirect creation that was conflicting with your trailingSlash: "never" configuration.

…ant redirects

- Removed creation of redundant redirects for page paths during CI builds
ref-actor Simplified(gatsby-node): simplify page creation and remove lite mode redirects env

CreatePage wrapper to directly call createPage
- Removed legacy lite mode redirects and related placeholder pages
- Simplified env- Retained all page templates andCreate GraphQL queries without modification
-Page function to directly call createPage without redirects
 Kept collection filtering and pagination- Removed redundant slug slash redirects in CI environment
 logic intact
- Kept existing GraphQL queries and page creation- No logic intact
- Maintained excluded collections handling and functional changes to node field creation or schema customization full site build flag
- Ensured dev
- Improved code clarity 404 page caching and webpack config remain unchanged by removing unnecessary redirect side effects

Signed-off-by: Abmarne <abhirajmarne11@gmail.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 15, 2026

🚀 Preview deployment: https://layer5.io/pr-preview/pr-7634/

Note: Preview may take a moment (GitHub Pages deployment in progress). Please wait and refresh. Track deployment here

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Removes CI-only redirect creation in gatsby-node.js that conflicted with the site’s trailingSlash: "never" setting, eliminating warnings about paths matching both a page and a redirect.

Changes:

  • Deleted CI-specific trailing-slash redirect logic in envCreatePage.
  • Simplified envCreatePage to directly call createPage with the provided props.

Comment thread gatsby-node.js
Comment on lines 56 to 58
const envCreatePage = (props) => {
const pageProps = {
...props,
};

if (process.env.CI === "true") {
const { path } = pageProps;
createRedirect({
fromPath: `/${path}/`,
toPath: `/${path}`,
redirectInBrowser: true,
isPermanent: true,
});
}

return createPage(pageProps);
return createPage(props);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Warnings when running npm run build

4 participants