Free auditStart free
GuideGatsby · URL changes

Gatsby redirects

Create Gatsby redirect rules, make sure your hosting adapter serves them, and test permanent URL changes after deployment.

3 min
read
4
sources
Oct 24, 2026
updated
Scaplet Editorial Team
author
In one line

Gatsby creates redirect definitions with its createRedirect action, usually from gatsby-node.js. A definition alone does not guarantee a live HTTP redirect: the deployment platform or adapter must implement it. Use a permanent server-side redirect for a URL that has moved for good, map each old route to its closest replacement, and test the deployed response and final destination.

30-second check

Where does your site stand?

Four quick questions, then a straight answer.

1/4Have you checked your own site for this?
Summarize this page withChatGPTClaudePerplexityGoogleAI Mode
01Checklist

Define the redirect in gatsby-node

Gatsby exposes createRedirect as an action in its Node APIs. Gatsby's redirect guide puts the calls inside createPages in gatsby-node.js. The target should be the closest surviving page; sending every removed URL to the home page can confuse visitors and may be treated as a soft 404.
First2
isPermanent defaults to a temporary redirect. Set isPermanent: true only when the old URL has actually been replaced for the long term. fromPath must start with a forward slash, and toPath is the URL of a created page.
Gatsby says to keep the redirects configuration in sync with the trailing slash configuration from the Gatsby Config API, and with your host's URL behavior.
Next2
ignoreCase, force and statusCode are not part of the Gatsby API. Only some plugins and adapters implement them, so check your host's docs before relying on them.
Do not redirect deleted content to an unrelated page; return a real 404 or 410 when there is no useful replacement.
Then1
Avoid chains: update old rules to point directly at the current destination.
gatsby-node.js
exports.createPages = ({ actions }) => {
  const { createRedirect } = actions

  createRedirect({
    fromPath: '/old-guides/redirects',
    toPath: '/seo/gatsby/redirects',
    isPermanent: true,
    redirectInBrowser: false,
  })
}
02Check the whole redirect path

Make the hosting platform serve the rule

Gatsby's createRedirect reference says redirects must be implemented by your deployment platform, using an adapter or plugins. Its page lists gatsby-plugin-meta-redirect, which generates meta redirect HTML files for redirecting on any static file host, and points to the source of gatsby-adapter-netlify to see how Netlify does it. The docs also say redirects work out of the box on Gatsby Cloud, but Gatsby's docs site now carries a banner about migrating to Netlify, so don't plan around Gatsby Cloud. On another host, configure that host's redirect file or adapter and confirm it emits an HTTP response. A meta or client-side redirect is not the same as a server response; prefer a server-side redirect.
Layer

Gatsby build

Question
Did the rule run?
Evidence
Build output or adapter-generated redirect artifact
Layer

Host/CDN

Question
Does the deployed host implement it?
Evidence
Host config or adapter docs
Layer

HTTP response

Question
Does the old URL return a redirect status?
Evidence
curl -I against production
Layer

Destination

Question
Does it resolve directly to the right canonical page?
Evidence
Final URL, status, content, and canonical tag

Adapters were added in gatsby@5.12.0. Per Gatsby's adapters guide, an adapter turns Gatsby's production output into something your platform understands and applies redirects and rewrites; the official adapter listed there is gatsby-adapter-netlify, with community adapters on npm under gatsby-adapter. Installing one does not prove the old path returns the intended response, so keep the curl -I check in a migration smoke test.

03How it works

Validate a Gatsby URL migration

  1. 1

    Inventory old paths

    Export the old URLs and map each to its equivalent new page. Preserve query parameters only when the destination uses them.

  2. 2

    Build and deploy

    Check the adapter or host output for the redirect rules, then publish the deployment.

  3. 3

    Request each old URL

    Use curl -I https://example.com/old-path and confirm a server-side 301 or 308 for permanent moves, with a Location pointing to the intended page.

  4. 4

    Update discovery signals

    Update internal links and the sitemap to use final URLs. Recheck a sample for loops, chains, 404s, and incorrect host or slash variants.

Google's indexing pipeline uses a permanent redirect as a signal that the destination should be canonical. For nearby implementation guides, see Gatsby SEO, XML sitemaps, and canonical URLs.

Questions

Asked a lot.

3 questions people ask next, answered from the sources on this page.

01How do I add a 301 redirect in Gatsby?

Call Gatsby’s createRedirect action with fromPath, toPath, and isPermanent: true (the default is temporary), then ensure your deployment adapter or host implements the redirect.

02Why does my Gatsby redirect work locally but not in production?

The production host may not implement Gatsby’s redirect definitions. Check the adapter and hosting configuration, then test the public HTTP response.

03Should I redirect every removed Gatsby page to the homepage?

No. Redirect to a closely equivalent replacement. If none exists, return a real not-found or gone response rather than a misleading destination.

Sources · 4

Every fact, linked and dated.

Official docs first. The date is when we last opened each page.
  • gatsbyjs.com
  • google.com
  1. 01Working with Redirects and Rewrites (Gatsby Cloud) | Gatsby Docsgatsbyjs.com · checked 2026-10-24
  2. 02createRedirect action | Gatsby Docsgatsbyjs.com · checked 2026-10-24
  3. 03Adapters | Gatsby Docsgatsbyjs.com · checked 2026-10-24
  4. 04Redirects and Google Search | Google Search Centraldevelopers.google.com · checked 2026-10-24
Free · 2 minutes

Tools point. Agencies advise. This one ships.

Run the free audit, then approve the fixes. Every change can be undone.

Free, no card60 secondsNobody will call you
  • 46 fixes shipped without a ticket Brightpipe
  • 0→7 ChatGPT citations in six weeks Paylane