This tutorial will guide you how to write an activity post.
Create a new file named YYYY-MM-DD-TITLE.EXTENSION
and put it in the _posts
of the root directory. Please note that the EXTENSION
must be one of md
and markdown
.
Basically, you need to fill the Front Matter as below at the top of the post:
1
2
3
4
5
6
---
title: TITLE
date: YYYY-MM-DD HH:MM:SS +/-TTTT
categories: [CATEGORIE] or [TOP_CATEGORIE, SUB_CATEGORIE]
tags: [TAG] # TAG names should always be lowercase
---
In order to accurately record the release date of a post, you should not only set up the timezone
of _config.yml
but also provide the post’s timezone in variable date
of its Front Matter block. Format: +/-TTTT
, e.g. +0800
.
The categories
of each post are designed to contain up to two elements, and the number of elements in tags
can be zero to infinity. For instance:
1
2
3
4
---
categories: [Animal, Insect]
tags: [bee]
---
For website performance reasons, the mathematical feature won’t be loaded by default. But it can be enabled by:
1
2
3
---
math: true
---
After enabling the mathematical feature, you can add math equations with the following syntax:
$$ math $$
with mandatory blank lines before and after $$
$$ math $$
without any blank line before or after $$
\$$ math $$
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<!-- Block math, keep all blank lines -->
$$
LaTeX_math_expression
$$
<!-- Inline math in lines, NO blank lines -->
"Lorem ipsum dolor sit amet, $$ LaTeX_math_expression $$ consectetur adipiscing elit."
<!-- Inline math in lists, escape the first `$` -->
1. \$$ LaTeX_math_expression $$
2. \$$ LaTeX_math_expression $$
3. \$$ LaTeX_math_expression $$
Add italics to the next line of an image, then it will become the caption and appear at the bottom of the image:
1
2

_Image Caption_
In order to prevent the page content layout from shifting when the image is loaded, we should set the width and height for each image.
1
{: width="700" height="400" }
For an SVG, you have to at least specify its width, otherwise it won’t be rendered.
Starting from Chirpy v5.0.0, height
and width
support abbreviations (height
→ h
, width
→ w
). The following example has the same effect as the above:
1
{: w="700" h="400" }
By default, the image is centered, but you can specify the position by using one of the classes normal
, left
, and right
.
Once the position is specified, the image caption should not be added.
Normal position
Image will be left aligned in below sample:
1
{: .normal }
Float to the left
1
{: .left }
Float to the right
1
{: .right }
When a post contains many images, it will be a time-consuming task to repeatedly define the path of the images. To solve this, we can define this path in the YAML block of the post:
1
2
3
---
img_path: /assets/img/activities
---
And then, the image source of Markdown can write the file name directly:
1

The output will be:
1
<img src="/assets/img/activities/figures.png" alt="The flower">
If you want to add an image at the top of the post, please provide an image with a resolution of 1200 x 630
. Please note that if the image aspect ratio does not meet 1.91 : 1
, the image will be scaled and cropped.
Knowing these prerequisites, you can start setting the image’s attribute:
1
2
3
4
5
---
image:
path: /path/to/image
alt: image alternative text
---
Note that the img_path
can also be passed to the preview image, that is, when it has been set, the attribute path
only needs the image file name.
For simple use, you can also just use image
to define the path.
1
2
3
---
image: /path/to/image
---
There are several types of prompts: tip
, info
, warning
, and danger
. They can be generated by adding the class prompt-{type}
to the blockquote. For example, define a prompt of type info
as follows:
1
2
> Example line for prompt.
{: .prompt-info }
1
`inline code part`
1
`/path/to/a/file.extend`{: .filepath}
Markdown symbols ```
can easily create a code block as follows:
1
2
3
```
This is a plaintext code snippet.
```
Using ```{language}
you will get a code block with syntax highlight:
1
2
3
```yaml
key: value
```
By default, all languages except plaintext
, console
, and terminal
will display line numbers. When you want to hide the line number of a code block, add the class nolineno
to it:
1
2
3
4
```shell
echo 'No more line numbers!'
```
{: .nolineno }
You may have noticed that the code language will be displayed at the top of the code block. If you want to replace it with the file name, you can add the attribute file
to achieve this:
1
2
3
4
```shell
# content
```
{: file="path/to/file" }
For more knowledge about Jekyll posts, visit the Jekyll Docs: Posts.