Format Markdown Files for Gatsby.js

InstructorTaylor Bell

Share this video with your friends

Send Tweet

Gatsby looks at the “frontmatter” at the top of each Markdown file when building your blog. In this lesson, you’ll learn how to add necessary information for building your posts.

Rob
~ 6 years ago

Bash oneliner to create the index.js files

✔ ~/devel/my-blog
10:56 $ for dir in src/pages/2018-10-19-* ; do touch $dir/index.md ;  done
✔ ~/devel/my-blog
10:57 $ tree ./src/pages/
./src/pages/
├── 2018-10-19-first-post
│   └── index.js
├── 2018-10-19-second-post
│   └── index.js
├── 2018-10-19-third-post
│   └── index.js
└── index.js

3 directories, 4 files

Thanks to @Farakh Malik for spotting a typo

Farakh Malik
~ 6 years ago

@Rob Thank you so much. Wish I saw this earlier! By the way: you have a typo, it should be 2018-10-19 instead of 20180-10-19

for dir in src/pages/2018-10-19-* ; do touch $dir/index.md ; done

Rob
~ 6 years ago

@Farakh you are welcome and that was a good spot, nice catch, thanks for that!

I'll edit it so that it is copy paste-able for the next passer by.