Creating Post

Create post

Setup

05/16/2020


header writing

Posts directory

  • To create a post with gatsby-blog-mdx, create *.mdx or *.mdx file under _posts directory

Feel free to choose either *.md or *.mdx as both extensions supports markdown and jsx (react component)

TEXT
.
├── _assets
├── _posts
└── ...
  • You can create any directory under posts. For example:
TEXT
├── _posts
| ├──2020
| | ├── first-post.mdx
| | └── second-post.mdx
| └── about.mdx
└── ...

Above two posts will automatically have their own directory available at:

  • yoursite.com/2020/first-post
  • yoursite.com/2020/second-post

Post description

MDX
---
title: First Post
date: 2020-03-10
draft: false # Optional
tags: [category1, category2] # Optional
excerpt: "This is my first post" # Optional
---
# Fist post
This is my first post
  • date: format is YYYY-MM-DD

    • [Optional]: You can add time such as YYYY-MM-DD HH:MM:SS. Time won't be shown in post, but it may be useful when ordering multiple posts written in the same day. i.e. post with date: 2020-03-10 00:00:01 will be displayed before/under one with 2020-03-10 00:00:02
  • draft: optional. But when it is set to draft: true, it won't be displayed in home page, though it will still be accessible by navigating to post's url

  • tag: when not specified, it will be displayed under Uncategorized tag

  • excerpt: when not specified, part of your post will be displayed in main page

    • For example, first-post has excerpt specified while second-post doesn't

      MDX
      ---
      title: "Second Post"
      date: 2020-02-28
      ---
      ## Second post
      This post does not have excerpt specified,
      thus it will show whatever content that you have in post in home page
      MDX
      ---
      title: "First Post"
      date: 2020-02-27
      excerpt: "This post has excerpt specified"
      ---
      ## First Post

      In main page, these posts will be displayed like this excerpt ex

About page

About page is available when viewer clicks your name (author name)

8

MDX
.
├── _posts
| ├── 2020
| | └── ...
| └── about.mdx
└── ...

about.mdx is located in _posts/ directory. You can modify this file just like how you'd create a post.

Don't like to have about page? Simply disable it in customize.js

What's next? 🤔

- Learn Markdown & Mdx

- Customize your blog

- Deploy Blog on Netlify💫


WRITTEN BY

My Simple blog

Austin, TX