score:5
Accepted answer
in gatsby-node.js
:
// implement the gatsby api “oncreatepage”. this is
// called after every page is created.
exports.oncreatepage = async ({ page, boundactioncreators }) => {
const { createpage } = boundactioncreators;
return new promise((resolve, reject) => {
if (page.path.match(/^\/landing-page/)) {
// it's assumed that `landingpage.js` exists in the `/layouts/` directory
page.layout = "landingpage";
// update the page.
createpage(page);
}
resolve();
});
};
create src/layouts/landingpage.js
. this will be the new layout template.
create src/pages/landing-page/index.js
. this will be the index page for the newly created layout template.
Source: stackoverflow.com
Related Query
- is is possible to have multiple layouts in Gatsby
- Is it possible to have multiple <Switch> in React.js?
- Is it possible to have multiple dataProviders in react-admin?
- Why is it not possible to have the same name of two StaticQuery elements on two different layouts for Gatsby?
- Is it possible to have multiple BrowserRouter in react app
- Is it possible to have multiple value-like attributes on a single html element?
- React Router v4 with multiple layouts
- A module cannot have multiple default exports
- Is it possible to use Jest with multiple presets at the same time?
- Can a react component have multiple areas for child content?
- How to create multiple pages from single json files in Gatsby
- Multiple Layouts with React Router v4
- How is the correct way to have multiple dataProviders in react-admin?
- ReactJS with material-ui is it possible to have the tooltip behaviour on hover of a div?
- Multiple installations of Global site tag (gtag.js) detected in Gatsby application
- Gatsby GraphQL query for multiple images
- Possible to have a dynamically height adjusted textarea without constant reflows?
- Is it possible to use the same <Context.Provider> on multiple components?
- Can I have multiple babel.config.js in a monorepo?
- Is it possible to have two states in one react component
- webpack-cli Running multiple commands at the same time is not possible
- Is it possible to set up material-ui AppBar/ToolBar to have a horizontal tab menu layout?
- Can I use multiple Layouts for different pages?
- Call function only after multiple states have completed updating
- ReactJS: How to have multiple SPA's on the same website
- How to have multiple row tabs in Material UI Tabs
- Gatsby keeps complaining Cannot query field "fields" on type "MarkdownRemark" when I have allMarkdownRemark
- Gatsby JS - Multiple pages pulling in markdown files with different categorys
- Is it possible to use React Hooks outside of functional component, or i have to use mobx or redux?
- Is it possible not to have to hardcode context root to user react-router
More Query from same tag
- How to make an electron react app, which has 2 windows - a general one and one for the Tray
- How to correctly implement the delete functionality in React Redux
- JSX conditional inline styling doesn't work
- Editable textbox in react js
- Nginx configuration issue with https on windows
- How can I render different component using onClick() function in React?
- React, unable to access array in object
- react build give me 'npm ERR! code ELIFECYCLE'
- no-unused-expressions on ternary
- How to use RouterLink with Microsoft FluentUI React Link component
- How can I convert string into an imported alias in React?
- How to retrieve data in PHP, sent from React js using fetch()?
- React Update state in parent component
- Reactjs store addresses in array
- Target not defined react
- CORS request did not succeed - react
- React: Is manual memoization necessary?
- TypeError: d[("get" + method)] is not a function in reactjs while reading data from firebase
- Routing between react and ASP.NET Core
- React-Router v4 <Route render={...} /> not displaying component
- How to trigger an onChange event on an input when its value changed by code in React?
- Pass Multer validation error to React Component
- React redux: Update nested state's boolean with another nested array of objects by comparing IDs
- React.js create a div that can move objects left and right
- React PWA - enforce update on click
- How to concatenate JSX components in React Native
- React form triggers button onClick with every input
- Change color of range column chart in ApexCharts
- Rails how to reuse JBuilder template in controller action
- React - For Loop conditional render - not working and infinite trigger