因為在設定hexo時必須修改一堆.yml檔,想說來了解一下它所以就做了這篇簡短的筆記。
簡介
yaml簡寫yml唸作耶某,很像json很好懂。
副檔名: .yaml or .yml
寫法
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| person: name: "Yuan" occupation: "Incoming Yahooer" age: !!float 26 birthday: 1994-09-22 15:00:00 gpa: !!str 3.2 favriate number: 1 male: true flaws: null hobbies: - "guitar" - "coding" - "statistics" fruits: ["mango", "apple"] friends: - name: "Anger" age: 25 - {name: "Book", age: 25} - name: "NaYue" age: 24 decription: > Study in Tokyo now. Recently built a blog with hexo and gitpage like what you see here. signature: | Yuan Waseda University email: howlen0319@gmail.com
|
- 可用縮排把上述資料包進person這object裡面
- !!可以強制轉型
- hobbies的寫法跟fruits互通
- friends下的三種寫法互通,都會被存成list
- decription後面的>,可以讓分段的文字被存成一行(分行之類的format不會被保存)
- 相反的,signature後面的|可以讓format被保存下來
進階寫法
1 2 3 4 5 6 7 8 9
| person: name: &name_var "Yuan" id: *name
base: &base var1: value1
foo: foo_var1: *base
|
- id透過*可以存取name_var也就是"Yuan"
- *也可以存取整個key-value pair
參考來源