Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.0] Can you set the layout component when creating pages? #1119

Closed
craigmulligan opened this issue Jun 7, 2017 · 3 comments
Closed

[1.0] Can you set the layout component when creating pages? #1119

craigmulligan opened this issue Jun 7, 2017 · 3 comments
Labels
type: question or discussion Issue discussing or asking a question about Gatsby

Comments

@craigmulligan
Copy link

Is this planned or somehow already possible?

@jquense
Copy link
Contributor

jquense commented Jun 7, 2017

Its possible via the onCreatePage page api in a gatsby-node file something like:

exports.onCreatePage = ({ page }) => {
  if (page.path.startsWith('/getting-started')) {
    page.layout = 'getting-started';
  } else if (page.path.startsWith('/components')) {
    page.layout = 'components';
  }
};

where layout corresponds to a component file in src/layouts

@KyleAMathews
Copy link
Contributor

Yes, that's intended to work... although while doing the RRv4 upgrade, I dropped support for multiple layouts due to the complexity of getting things to work period. I'm finishing a refactor to this part of the code this morning which simplifies things a ton and should make it far easier to support:

  1. multiple layouts
  2. adding queries to layouts
  3. hierarchical layouts

@craigmulligan
Copy link
Author

Amazing, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question or discussion Issue discussing or asking a question about Gatsby
Projects
None yet
Development

No branches or pull requests

5 participants