Dato with Gatsby

So, I have a working Gatsby with dato starter project. while I was going through the code I have found src/posts/{DatoCmsPost.slug}.js file.

From the behavior, I could understand it is like a template. But when I try to change the name of the js file it crashes and I am confused why it is crashing over the change of file name.

  1. why do we use curly braces in the file name?
  2. how do we generate the name of the file if that is the case?
  3. how does it get the url-slug inside the component?

Hello @natyjava8 I think you want to have a look at this documentation here: https://www.gatsbyjs.com/docs/reference/routing/file-system-route-api/

1 Like