question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`layout` option of `createPage` does not work

See original GitHub issue

Description

layout option of createPage does not work. As this document https://www.gatsbyjs.org/docs/creating-and-modifying-pages/#creating-pages-in-gatsby-nodejs, layout option can be passed to createPage API so Gatsby can get a template from layouts/${layout} folder.

Environment

Gatsby version: 1.9.138 Node.js version: v8.9.3 Operating System: Mac OS High Sierra 10.13.2

Actual result

If layout option is passed an value to createPages API, ex: ‘blog-layout’, layouts/blog-layout.js is not loaded. So I have to ignore the layout - don’t pass any value, in order to Gatsby falls to default value to load layouts/index.js file.

Expected behavior

layout option should work like in the document (https://www.gatsbyjs.org/docs/creating-and-modifying-pages/#creating-pages-in-gatsby-nodejs) mentions.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
belbiycommented, Feb 3, 2018

I’m also having this issue as well, using exports.createPages like this

createPage({
    path: node.data.path,
    layout: 'custom-layout',
    component: path.resolve(node.node.absolutePath),
})

Still uses the index layout.

But when I apply layout from exports.onCreatePage it works.

0reactions
KyleAMathewscommented, Sep 8, 2018

Due to the high volume of issues, we’re closing out older ones without recent activity. Please open a new issue if you need help!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Creating and Modifying Pages - Gatsby
Gatsby makes it easy to programmatically control your pages. Pages can be created in three ways: By creating React components in the src/pages...
Read more >
Gatsby Query createPage context options from page template
Pass context to pages. When in doubt, check the docs. import React from 'react' import { graphql } from 'gatsby' const Page =...
Read more >
Create and use page templates in Pages on Mac
In Pages on your Mac, create page templates for page layout documents. ... Changes you make in your document don't affect the page...
Read more >
Create Page Layouts - Salesforce Help
With the enhanced page layout editor, you can tailor record page layouts to the needs of your users. Add, remove, or reorder actions,...
Read more >
Page Setup - Microsoft Support
Use the Page Setup dialog box to set up layout and print options of a page. Click on the Page Layout tab, then...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found