What I've learnt so far from with Hugo framework

1. Trying to define a variable in IF block does NOT work

If you learn Python, you can do something like this:

1if goodWeather == True:
2  shirtColor = "Yellow"
3else:
4  shirtColor = "Black"

The variable shirtColor will be defined after if block. However, it is not the case for Hugo framework. You have to define the variable outside the IF block first.

2. Unsafe markdown renderer maybe useful

If unsafe = false, you can not use html code inside your .md files.

1[markup]
2  [markup.goldmark]
3    [markup.goldmark.renderer]
4      unsafe = true

3. _index.md might become a problem

Suppose I have a tree directory like this:

└── posts/
    ├── _index.md
    ├── poetry/
    │   ├── buffalo.md
    │   └── _index.md
    └── photogallery/
        ├── newyorkcitytrip.md
        ├── cats.md
        └── _index.md

The _index.md in poetry is neccessary to generate a list of posts in this folder. It treats those subdirectories (poetry and photogallery) as “Leaf Bundles”. This means that any other content files in those subdirectories are considered Page Resources rather than standalone pages with their own permalinks. Therefore, the “posts” page will be generated without “buffalo”, “newyorkcitytrip” and “cats” links.

To by pass this problem, we can try to define $Paginator in posts and other folders in different ways.

1{{- if eq .Permalink (absURL "/posts/")}}
2Do something
3{{- else }}
4Do something
5{{- end }}