Gatsby site from scratch #14: Autogenerating URLs from files with onCreateNode

Опубликовано: 23 Март 2026
на канале: Swashbuckling with Code
383
12

Using `createFilePath` from `gatsby-source-filesystem` and `onCreateNode` from the Gatsby API we can auto generate slugs based on the file name and fix the issue we had in the previous video. That issue was caused by writing the slug in each markdown file manually without adding a trailing slash at the end.

00:00 - Intro
00:20 - Quick recap and showing the process
03:32 - Why static sites default to trailing slash
05:30 - Manually adding trailing slash to frontmatter
07:05 - Looking at Gatsby Starter Blog source code
09:12 - Adding onCreateNode to our site
13:14 - Changing our markdown query to grab the field
17:20 - Deploying and more onCreateNode breakdown
21:18 - Checking lighthouse against our new build
22:48 - Time warp after days troubleshooting

Previous video in the series:
   • Gatsby site from scratch #13: Progressive ...  

Next video in the series:
   • Gatsby site from scratch #15: Listing all ...  

Follow Jimmy Cleveland's doings:
blog: https://blog.jimmydc.com/
twitter:   / jimmydcleveland  

#gatsbyjs #ssg #pwa