Gatsby Markdown

Building a blog with Markdown files

Gatsby Markdown

by John Vincent


Posted on September 20, 2019


Let's build Markdown pages with Gatsby.

Gatsby Markdown Plugin

Using the plugin gatsby-transformer-remark, add to gatsby-config.js

{
	resolve: `gatsby-transformer-remark`,
	options: {
		excerpt_separator: `<!-- end -->`,
		plugins: [`gatsby-plugin-catch-links`],
	},
},

Use the excerpt_separator in your markdown files to notify the parser of the end of your excerpt.

Gatsby needs to know where to find the markdown files

{
	resolve: `gatsby-source-filesystem`,
	options: {
		name: `markdown-content`,
		path: `${__dirname}/src/markdown/content`,
	},
},
{
	resolve: `gatsby-source-filesystem`,
	options: {
		name: `markdown-blogs`,
		path: `${__dirname}/src/markdown/blogs`,
	},
},

My markdown files have different purposes and need to be handled differently in gatsby-node.js

gatsby-node.js generates the pages of the website.