score:0

if you are creating a spa (single page application, notice the single) you won't have any created pages but index. you are trying yo access to a /category page that's not created because of:

  if (page.path === "/") {
    page.matchpath = "/*"
    createpage(page)
  }

that's why your routes don't work (or in other words, only the home page works).

adapt the previous condition to your needs to allow creating more pages based on your requirements.

i'm using gatsby and i want build a single page site, so without create pages. for achieve this i edited gatsby-node.js with the following code:

it's a non-sense trying to build a spa application with gatsby (without creating pages) but then complaining because there's not collection page created.

make sure that you understand what you are doing, it seems clearly that you need to create dynamically pages for each collection, season, and product so your approach to create spa won't work for your use-case.

it's possible to keep just index.js without overcomplicating thing? i just want to understand why my code isn't working 'cause i've passed the correct url... removing the localization gatsby works, so i suspect there is a localization problem

the only way that http://localhost:3001/category-home/prod-foo (removing the localization) could be resolved is by creating a folder structure such /pages/category-home/prod-foo.js (since gatsby extrapolates the folder structure as urls), so, if you want to use localization using your approach, add a structure such en/pages/category-home/prod-foo.js and es/pages/category-home/prod-foo.js (or the whatever locale), and so on. in my opinion, this is overcomplexitying stuff since, for every category, you'll need to create 2 (even more depending on the locales) files.

gatsby allows you to create dynamic pages and interpolate the locale automatically using built-in plugins on the process, creating each file for the specifically defined locales.


Related Query

More Query from same tag