diff --git a/gatsby-node.js b/gatsby-node.js index d9216b65b..66a6b744f 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -96,19 +96,24 @@ exports.createPages = async ({ actions, graphql, reporter }) => { }); } - if (frontmatter.path !== slug) { - const newPath = path.join( + if (frontmatter.path) { + const recommendedPath = path.join( 'src/markdown-pages', fileRelativePath.endsWith('index.mdx') ? path.join(frontmatter.path, 'index.mdx') : `${frontmatter.path}.mdx` ); - reporter.error( + const recommendation = + recommendedPath === fileRelativePath + ? "Please remove the 'path' property." + : `To render this page at '${frontmatter.path}', please move this file to: '${recommendedPath}'.`; + + reporter.panicOnBuild( ` -File path does not match frontmatter path: - mkdir -p ${path.dirname(newPath)} - mv ${fileRelativePath} ${newPath} +${fileRelativePath} + +The 'path' property on frontmatter is deprecated and has no effect. URLs are now generated using the path of the file. ${recommendation} `.trim() ); }