Using Multiple Page Templates for the Same Data Souce in GatsbyJS

You have been tasked with developing two sections for a web site. Each section has its own page layout. The content providers will produce Markdown files as the data source.

You create page templates for each section. Each template has a differnt purpose. How do you create pages using page templates you created? How do you use multiple templates? How do you create pages for the same data source but using different templates conditioned on design requirements? Does the gatsby-node.js file confuse you?

Recently, I created a web site that sourced Markdown files for more than one section of the site. One section used a blog post template. Another section produced pages in a content section with a sidebar containing links to each of the content pages. This meant I needed to create pages using a more refined approach than just the gatsby-source-filesystem plugin.

Lets look an approach to solve this problem.

Set Up

gatsby-config.js requirements

gatsby-node setup

© 2020, Built with Gatsby, hosted on Netlify