IsNode
IsNode 方法用於判斷 Page 物件是否為節點頁面。如果頁面類型為 home、section、taxonomy 或 term,則返回 true;如果頁面類型為 page,則返回 false。
用法範例
以下是頁面結構的範例:
content/
├── books/
│ ├── book-1/
│ │ └── index.md <-- kind = page, node = false
│ ├── book-2.md <-- kind = page, node = false
│ └── _index.md <-- kind = section, node = true
├── tags/
│ ├── fiction/
│ │ └── _index.md <-- kind = term, node = true
│ └── _index.md <-- kind = taxonomy, node = true
└── _index.md <-- kind = home, node = true
以下是如何在模板中使用 IsNode 方法:
{{ .IsNode }}