Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

114
Views
Filtering the Gatsby Slug in onCreateNode

I'm trying to filter the slug generated by Gatsby so I can remove white space and replace it with "-". I have Gatsby's reporter set to fire when onCreateNode is ran but it never seems to fire regardless of clearing the cache first. When I check in GraphiQL it shows no change to the slug. Here is my gastby-node.js onCreateNode:

exports.onCreateNode = ({ node, getNode, actions, reporter }) => {
reporter.info(`onCreateNode called from gatsby-node`)
const { createNodeField } = actions
if (node.internal.type === `MarkdownRemark`) {
    const slug = createFilePath({ node, getNode, basePath: `posts` }).replace(
        ' ',
        '-'
    )
    createNodeField({
        node,
        name: `slug`,
        value: slug
    })
}}

Any input would be greatly appreciated!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

There ended up being two instances of onCreateNode() in my gatsby-node.js file. Only one of them was being called during build. Removing the second instance of onCreateNode() solved my problem.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!