This tutorial will guide you how to write an activity post.

Naming and Path

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.

Front Matter

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

Timezone of Date

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.

Categories and Tags

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]
---

Mathematics

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:

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 $$

Images

Caption

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
![img-description](/path/to/image)
_Image Caption_

Size

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
![Desktop View](/assets/img/sample/mockup.png){: 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 (heighth, widthw). The following example has the same effect as the above:

1
![Desktop View](/assets/img/sample/mockup.png){: w="700" h="400" }

Position

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.

Image Path

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 figure](figures.png)

The output will be:

1
<img src="/assets/img/activities/figures.png" alt="The flower">

Preview Image

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

Prompts

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 }

Syntax

Inline Code

1
`inline code part`

Filepath Hightlight

1
`/path/to/a/file.extend`{: .filepath}

Code Block

Markdown symbols ``` can easily create a code block as follows:

1
2
3
```
This is a plaintext code snippet.
```

Specifying Language

Using ```{language} you will get a code block with syntax highlight:

1
2
3
```yaml
key: value
```

Line Number

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 }

Specifying the Filename

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" }

Learn More

For more knowledge about Jekyll posts, visit the Jekyll Docs: Posts.