Hashes in front matter?

Am I correct that the most complex data type I can use in front matter is a list? There isn’t a hash aka dictionary aka key-value-pair thingy?

(Would be nice if there were. e.g.

elsewhere: {
    twitter : @example,
    facebook: ex.ample
    ...
}

)

Try wrapping the values that contain special characters in bacticks i.e. `

This question wasn’t about the @ special character but about data structures :slight_smile:

Depending on which syntax you’re using for your front matter…

JSON

{
  "date": "2020-05-15T23:34:47-04:00",
  "draft": false,
  "title": "JSON",
  "elsewhere": {
    "twitter": "@example",
    "facebook": "ex.ample"
  }
}

- Twitter: {{< param elsewhere.twitter >}}  
- Facebook: {{< param elsewhere.facebook >}}

TOML

+++
date = 2020-05-15T23:34:47-04:00
draft = false
title = "TOML"
[elsewhere]
  twitter = "@example"
  facebook = "ex.ample"
+++

- Twitter: {{< param elsewhere.twitter >}}  
- Facebook: {{< param elsewhere.facebook >}}

YAML

---
date: 2020-05-15T23:35:04-04:00
draft: false
title: "YAML"
elsewhere:
  twitter: "@example"
  facebook: "ex.ample"
---

- Twitter: {{< param elsewhere.twitter >}}  
- Facebook: {{< param elsewhere.facebook >}}

The table indentation for TOML is optional, though I find it easier to read when indented. Regardless of which syntax you use for your front matter, you can nest as many levels as you need. The TOML documentation is here:

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.