From 912088f223c8877e2f38d75473dee4b3e4e5edef Mon Sep 17 00:00:00 2001 From: Devin Logan Date: Mon, 15 Sep 2025 13:04:51 -0400 Subject: [PATCH] move redirects info into a snippet, make clarifying updates --- .../pages/customization/what-is-docs-yml.mdx | 20 +-------- fern/products/docs/pages/seo/redirects.mdx | 41 +------------------ fern/snippets/redirects.mdx | 38 +++++++++++++++++ 3 files changed, 40 insertions(+), 59 deletions(-) create mode 100644 fern/snippets/redirects.mdx diff --git a/fern/products/docs/pages/customization/what-is-docs-yml.mdx b/fern/products/docs/pages/customization/what-is-docs-yml.mdx index 6be32a106..f5c87aeee 100644 --- a/fern/products/docs/pages/customization/what-is-docs-yml.mdx +++ b/fern/products/docs/pages/customization/what-is-docs-yml.mdx @@ -211,25 +211,7 @@ logo: ## Redirects configuration -```yaml docs.yml -redirects: - - source: "/old-path" - destination: "/new-path" - - source: "/old-folder/*" - destination: "/new-folder/*" -``` - - - The path that you want to redirect from. - - - - The path that you want to redirect to. - - - - Toggle between **permanent** and **temporary** redirect (default `false`). When true, the status code is 308. When false the status code is 307. - + ## NavBar links configuration diff --git a/fern/products/docs/pages/seo/redirects.mdx b/fern/products/docs/pages/seo/redirects.mdx index 3e5eef74d..b06ae9a5e 100644 --- a/fern/products/docs/pages/seo/redirects.mdx +++ b/fern/products/docs/pages/seo/redirects.mdx @@ -5,46 +5,7 @@ subtitle: Set up the navigation for your documentation site built with Fern Docs ## Redirects -The `redirects` object allows you to redirect traffic from one path to another. You can redirect exact paths or use dynamic patterns with [`regex`](https://www.npmjs.com/package/path-to-regexp) parameters like `:slug`. - - - - ```yml - redirects: - # Exact path redirects - - source: "/old-path" - destination: "/new-path" - - source: "/old-folder/path" - destination: "/new-folder/path" - - # Regex-based redirects - - source: "/old-folder/:slug" # <- /old-folder/foo, /old-folder/bar, etc. - destination: "/new-folder/:slug" - - source: "/old-folder/:slug*" # <- /incorrect, /incorrect/foo/bar/baz, etc. - destination: "/new-folder/:slug*" - ``` - - - - Parameters suffixed with an asterisk (`*`) denote a match with zero or more. - - -### Setting permanent redirects - -By default, the redirects implement temporary (302) redirects. If you would like to implement permanent (301) redirects, you can set `permanent: true`. - - - ```yml - redirects: - - source: "/old-subdomain" - destination: "/new-subdomain" - permanent: true - ``` - - - - If your docs are hosted on a subpath (like `buildwithfern.com/learn`), be sure to include the subpath in the redirect. - + ## Links diff --git a/fern/snippets/redirects.mdx b/fern/snippets/redirects.mdx new file mode 100644 index 000000000..b0c94313d --- /dev/null +++ b/fern/snippets/redirects.mdx @@ -0,0 +1,38 @@ +The `redirects` object allows you to redirect traffic from one path to another. You can redirect exact paths or use dynamic patterns with [`regex`](https://www.npmjs.com/package/path-to-regexp) parameters like `:slug`. + +If your docs are hosted on a subpath (like `buildwithfern.com/learn`), include the subpath in both the source and destination paths. + + + + ```yml + redirects: + # Exact path redirects + - source: "/old-path" + destination: "/new-path" + - source: "/old-folder/path" + destination: "/new-folder/path" + permanent: true + + # Regex-based redirects + - source: "/old-folder/:slug" # <- /old-folder/foo, /old-folder/bar, etc. + destination: "/new-folder/:slug" + - source: "/old-folder/:slug*" # <- /incorrect, /incorrect/foo/bar/baz, etc. + destination: "/new-folder/:slug*" + ``` + + + + Parameters suffixed with an asterisk (`*`) match zero or more path segments, capturing everything that follows in the URL. Use this when redirecting entire folder structures while preserving nested paths. + + + + The path that you want to redirect from. + + + + The path that you want to redirect to. + + + + Toggle between **permanent** and **temporary** redirect (default `false`). When true, the status code is 308. When false, the status code is 307. +