Change Blog Post Folder Name Structure in GatsbyJS v2 Starter Blog

Wat is he talking about?
I still don’t see the problem
Drum roll please!
// In your gatsby-node.js
exports.onCreateNode = ({ node, actions, getNode }) => {
const { createNodeField } = actions
if (node.internal.type === `MarkdownRemark`) {
// This removes the MMDDYY-- from the front of each directory,
// that way a post name is just the remainder of the directory
// name, which in my case happens to be the blog post title
const value = createFilePath({ node, getNode })
.replace(/\d{6}--/, '')


createNodeField({
name: `slug`,
node,
value,
})
}
}

--

--

https://gunnariauvinen.com

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store