⚠️ This lesson is retired and might contain outdated information.

Format Markdown Files for Gatsby.js

Taylor Bell
InstructorTaylor Bell
Share this video with your friends

Social Share Links

Send Tweet
Published 6 years ago
Updated 2 years ago

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.

Instructor: [00:00] I'm in the My Blog directory, and I'm going to add a few posts. I'm going to do CD Source/Pages. Then, I like to do posts with the year, month, date, and a slug. I'll create a few of those. With those made, I'm going to create an index.md file in each one of the directories, which will be where our post is. With those made, let's go ahead and edit the first post.

[00:24] At the top of each post, we'll create some front matter, which is what will be used to create our posts. We'll add a few dashes. We'll start with a path. That'll be /firstpost. Then, we'll do a date.

[00:35] We'll do year, month, day. Add a title, add some tags, and a little excerpt. Then, close out our three dashes. Below this, we can start writing our post. Go ahead and follow this same pattern for all posts that you create.

Rob
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
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
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.

Markdown supported.
Become a member to join the discussionEnroll Today