Gatsby: Create Index.js from `createPages`

Created on 22 Aug 2018  路  3Comments  路  Source: gatsbyjs/gatsby

I want to pass data from a markdown file called index.md (edited via NetlifyCMS) to the index page.
If i use createPages as per the documentation and define a template for that file to build from it builds fine and I get a page at siteurl.com/index but my browser shows my 404 error page when going to siteurl.com

Couldn't see documentation anywhere? Can't imagine this is too hard?

Most helpful comment

Okay, it's actually trivially possible by passing path: "/" to createPage.

createPage({
  path: `/`,
  component: path.resolve("./src/components/siteRoot.js"),
  context: {
    repo_a: data.github.repositoryOwner.repositories.nodes,
  }
})

All 3 comments

Figured a work around out for my use case

I have the same problem. I'd like to get an answer to this question. Could it be reopened please?

Okay, it's actually trivially possible by passing path: "/" to createPage.

createPage({
  path: `/`,
  component: path.resolve("./src/components/siteRoot.js"),
  context: {
    repo_a: data.github.repositoryOwner.repositories.nodes,
  }
})
Was this page helpful?
0 / 5 - 0 ratings

Related issues

theduke picture theduke  路  3Comments

kalinchernev picture kalinchernev  路  3Comments

jimfilippou picture jimfilippou  路  3Comments

totsteps picture totsteps  路  3Comments

hobochild picture hobochild  路  3Comments