Skip to content

Commit

Permalink
chore(docs): Pre-encoded unicode characters can't be used in paths (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Auspicus committed Aug 9, 2022
1 parent 2bbe96d commit 0ed362c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/docs/reference/routing/creating-routes.md
Expand Up @@ -83,6 +83,8 @@ exports.createPages = async function ({ actions, graphql }) {

The data for creating these pages doesn't necessarily have to come from Gatsby's internal GraphQL data layer. For example, you can source local files or make async calls to remote APIs. For more information, please see [Creating and Modifying Pages](/docs/creating-and-modifying-pages/).

`path` must not be pre-encoded (ie. using `encodeURI`) however unicode characters are supported. So for a path like `/exámple` pass the string directly. Do not pass `encodeURI('/exámple')` or `/ex%C3%A1mple`. If you receive pre-encoded paths from your CMS you may want to run them through `decodeURI` first to ensure the special characters (eg. `%C3%A1`) are turned back into unicode.

## Conflicting Routes

Since there are multiple ways to create a page, different plugins, themes, or sections of code in your `gatsby-node` file may accidentally create multiple pages that are meant to be accessed by the same path. When this happens, Gatsby will show a warning at build time, but the site will still build successfully. In this situation, the page that was built last will be accessible and any other conflicting pages will not be. Changing any conflicting paths to produce unique URLs should clear up the problem.
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby/src/redux/actions/public.js
Expand Up @@ -155,7 +155,7 @@ const reservedFields = [
* Create a page. See [the guide on creating and modifying pages](/docs/creating-and-modifying-pages/)
* for detailed documentation about creating pages.
* @param {Object} page a page object
* @param {string} page.path Any valid URL. Must start with a forward slash
* @param {string} page.path Any valid URL. Must start with a forward slash. Unicode characters should be passed directly and not encoded (eg. `á` not `%C3%A1`).
* @param {string} page.matchPath Path that Reach Router uses to match the page on the client side.
* Also see docs on [matchPath](/docs/gatsby-internals-terminology/#matchpath)
* @param {string} page.ownerNodeId The id of the node that owns this page. This is used for routing users to previews via the unstable_createNodeManifest public action. Since multiple nodes can be queried on a single page, this allows the user to tell us which node is the main node for the page. Note that the ownerNodeId must be for a node which is queried on this page via a GraphQL query.
Expand Down

0 comments on commit 0ed362c

Please sign in to comment.