-
Create a Gatsby site.
Use the Gatsby CLI to create a new site, specifying the blog starter.
# create a new Gatsby site using the blog starter gatsby new my-blog-starter https://github.com/acdzh/gatsby-theme-rapid
-
Modify the Site's Config. Modify the config in
./gatsby-config.js
; -
Create Content Directory. Create a directory like this:
content โโโ blog โโโ static
You blogs should be
.md
files in theblog
directory, and the everything in thestatic
directory would be copied to the root path when after building. -
Preview
yarn dev --host 0.0.0.0
Then you can see the site running at
http://localhost:8000/
You can create a new article easily just like this:
yarn run new <article_name>
For Example:
yarn run new '/2021/this is my first article'
## or
yarn run new '/2021/this is my first article.md'
It will create the file at ./content/blog/2021/this is my first article.md
.
Another way, if you add a /
at the end of <article_name>
like yarn run new '/2021/this is my first article/'
It will create the file at ./content/blog/2021/this is my first article/index.md
.
By the way, the final effect of these two methods is equivalent.
There are many prams of an article.
params name | requied | default value | |
---|---|---|---|
title | โ | ${filename} | The title of this article which will show in the post page and the list view. |
date | โ | ${now.format()} | |
draft | โ | false | This article will not be published when draft is true . |
comment | โ | true | Whether this article can be commented. |
description | โ | ${the content of this article} | It will show after the title in the list page. |
author | โ | ${the author infomation from global config} | The author. |
from | โ | Whether this article comes from if it is Is reprinted. | |
slug | โ | ${title} | The url slug |
cover | โ | Cover image. | |
tags | โ | [] | List of tags. |
series | โ | [] | List of series. |
categories | โ | [] | List of categories. |
just ![](./image.jpg)
or ![](https://example.com/img.jpg)
To Preview see https://blog.acdzh.com/post/shortcode_test/
Every available Short Code is at: ./src/templates/post-components.tsx
yarn build
Then publish the ./public
folder.